The Ultimate Guide to URL Encoding in ASP.NET.

I'm starting to realize that there are about a bazillion different methods of encoding URLs in .NET. I keep finding new ones. They all work differently, but they all have the same comments.

Does anyone have a specific matrix that shows the exact differences between the following methods:

HttpUtility.UrlEncode
HttpUtility.UrlPathEncode
Server.UrlEncode
Uri.EscapeUriString
Uri.EscapeDataString

... are they bigger?

It would also be nice to match them with usage examples, for example:

  • URLs in href tag attributes
  • URL to display to user in HTML
  • Declares as request values ​​(i.e. sent in GET requests)
  • URLs are sent in POST requests, etc.
+3
source share
1 answer
0

Source: https://habr.com/ru/post/1741024/


All Articles