A definitive guide to Url Encoding in ASP .NET
Posted
by cbp
on Stack Overflow
See other posts from Stack Overflow
or by cbp
Published on 2010-04-14T02:26:05Z
Indexed on
2010/04/14
2:33 UTC
Read the original article
Hit count: 500
I am starting to realise that there are about a bazillion different methods for encoding urls in .NET. I keep finding new ones. They all work slightly differently, but they all have essentially the same summary comments.
Does anyone have a definitive matrix that shows the exact differences between the following methods:
HttpUtility.UrlEncode
HttpUtility.UrlPathEncode
Server.UrlEncode
Uri.EscapeUriString
Uri.EscapeDataString
... are they any more?
Also it would be good to match these up with use-cases e.g.:
- Urls in href attributes of a tags
- Urls to be displayed to the user in HTML
- Urls as querystring values (i.e. to be sent in GET requests)
- Urls to be sent in POST requests etc
© Stack Overflow or respective owner