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:



  Modified On Sep-18-2014 01:23:53 PM

Leave Comment