Home > DeveloperSection > Blogs > Encode - Decode in ASP.NET

Encode - Decode in ASP.NET

ASP.Net ASP.Net 
0 Comment(s)
 2984  View(s)
Rate this:

Encode and Decode in ASP.Net


Html Encode method encodes a particular string to be displayed in a browser. It is important to encode strings prior it’s rendering in the page, mainly to avoid cross-site script injection (XSS) and HTML injection attacks. However, developers so often forget to call the encode function.

Html Decode method decodes a particular string which is encoded.

Encoding and decoding is needed in somewhere like

·         Pass the values from one page to another.

·         Access the URL or pass the URL.

·         Fetch the data or insert data in Database.

·         Read the xml data or insert data in xml.

·         Change the special character from string

·         And security purpose etc.


In ASP.Net we used the following encode and decode method:

·         Server.HtmlEncode()

·         Server.HtmlDecode()

·         Server.HtmlUrlEncode()

·         Server.HtmlUrlDecode ()

·         HttpUtility.UrlEncode()

·         HttpUtility.UrlDecode ()


Check details here:




Don't want to miss updates? Please click the below button!

Follow MindStick