- UrlEncode () method, there are two classes that have this method, namely Httputility.urlencode and Server.URLEncode
Difference:
1, Httputility.urlencode,httputility.urldecode is a static method, and Server.urlencode,server.urldecode is an instance method.
2. Server is an instance of the HttpServerUtility class, and is the attribute of System.Web.UI.Page.
3. Httputility.urlencode encoded strings and string objects encoded with Server.URLEncode are not the same?
4. Server.URLEncode can be encoded according to your page's defined encoding. and? Httputility.urldecode is encoded by default in UTF8. Otherwise you'll need to specify your own encoding method:
(ref:http://www.cnblogs.com/akak123/archive/2012/06/13/2547790.html)
- Function: URL-encodes a string and returns the encoded string.
Note: International general, prevent garbled. Corresponding to this is the urldecode operation.
The content to encode is not necessarily a URL, but a string in essence
- Where to use it now:
- When you complete the file download requirement, Httputility.urlencode
- When writing data to a cookie, Server.URLEncode and Server.urldecode
20140115-url encoding and decoding