Reputation: 12437
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.
Upvotes: 2
Views: 3507
Reputation: 712
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");
Upvotes: 9
Reputation: 55760
Have a look at UrlEncode of the HttpServerUtility:
HttpServerUtility.UrlEncode("http://www.test.com/images/tony's pics.jpg");
Upvotes: 0