URL Encoding & Decoding in Asp.net using cSharp

30. January 2010

Author: Aamir Hasan

UrlEncode it is the process of converting string into valid URL format as specification of w3.org

string URLEncode = Server.UrlEncode("aamirhasan.aspx?Name = aamirhasan&ID = 23");

Response.Write("Encoding URL:-" + URLEncode);



//show like this aamirhasan.aspx%3f+Name+%3d+aamirhasan%26ID+%3d+23
UrlDecode:- URL-decodes a string and returns the decoded string.

string URLDecode = Server.UrlDecode(URLEncode);

Response.Write("Decoding URL:-" + URLDecode);

 


//show like this aamirhasan.aspx?Name = aamirhasan&ID = 23

Online Encode and Decode :http://www.opinionatedgeek.com/DotNet/Tools/HTMLEncode/Encode.aspx

References:

http://msdn.microsoft.com/en-us/library/zttxte6w.aspx
http://msdn.microsoft.com/en-us/library/6196h3wt.aspx


Author: Aamir Hasan     औथोर: आमिर हसन       أثر أمير حسن .

ALL, asp.net ,



User Name: Guest

Your Ip: 38.107.191.91
Time: