2

I have a string that contains a url which looks like this:

http://www.test.com/images/tony's pics.jpg

I need the url to look like this:

http://www.test.com/images/tony%27s%20pics.jpg

How would I programmatically solve this with a url in a STRING form. Thanks.

2

2 Answers 2

9

I would think this would easily be solved by using the HttpUtility UrlEncode:

string url = "http://www.test.com/images/" + HttpUtility.UrlEncode("tony's pics.jpg");
Sign up to request clarification or add additional context in comments.

1 Comment

This is going to result in http%3a%2f%2fwww.google.com%2fsearch%3fq%3dExample
0

Have a look at UrlEncode of the HttpServerUtility:

HttpServerUtility.UrlEncode("http://www.test.com/images/tony's pics.jpg");

1 Comment

This is going to result in http%3a%2f%2fwww.google.com%2fsearch%3fq%3dExample

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.