Timeline for answer to URL Encoding using C# by DanHerbert
Current License: CC BY-SA 2.5
Post Revisions
6 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| May 23, 2017 at 12:02 | history | edited | URL Rewriter Bot | replaced http://stackoverflow.com/ with https://stackoverflow.com/ | |
| Apr 11, 2014 at 7:25 | comment | added | Wiseman | HttpUtility is succeeded by WebUtility in latest versions, save yourself some time :) | |
| Nov 29, 2010 at 18:23 | comment | added | Tim Goodman | See here: connect.microsoft.com/VisualStudio/feedback/details/551839/… I should add that of course it's good that UrlPathEncode doesn't encode &, because you need that to delimit your query string parameters. But there are times when you want encoded ampersands as well. | |
| Nov 29, 2010 at 18:21 | comment | added | Tim Goodman | @DJ Pirtu: It's true that UrlPathEncode won't make those undesired changes in the path, however it also won't encode anything after the ? (since it assumes the query string is already encoded). In Dan Herbert's example it looks like he's pretending Example is the text that requires encoding, so HttpUtility.UrlPathEncode("http://www.google.com/search?q=Example"); won't work. Try it with ?q=Ex&ple (where the desired result is ?q=Ex%26ple). It won't work because (1) UrlPathEncode doesn't touch anything after ?, and (2) UrlPathEncode doesn't encode & anyway. | |
| Mar 9, 2009 at 10:08 | comment | added | vipirtti | Using the HttpUtility.UrlPathEncode method should prevent the problem you're describing here. | |
| Feb 22, 2009 at 21:29 | history | answered | Dan Herbert | CC BY-SA 2.5 |