This documentation is archived and is not being maintained.

HttpServerUtility.HtmlDecode Method (String, TextWriter)

.NET Framework 1.1

Decodes an HTML-encoded string and sends the resulting output to a TextWriter output stream.

[Visual Basic]
Overloads Public Sub HtmlDecode( _
   ByVal s As String, _
   ByVal output As TextWriter _
public void HtmlDecode(
 string s,
 TextWriter output
public: void HtmlDecode(
 String* s,
 TextWriter* output
public function HtmlDecode(
   s : String,
 output : TextWriter


The HTML string to decode.
The TextWriter output stream containing the decoded string.


URL encoding ensures that all browsers will correctly transmit text in URL strings. Characters such as ?, &,/, and spaces may be truncated or corrupted by some browsers so those characters must be encoded in <A> tags or in query strings where the strings may be re-sent by a browser in a request string. HtmlDecode decodes text that has been transmitted to the server.


The following example decodes a string that has been HTML-encoded for transmission over HTTP. It decodes the supplied string named EncodedString which contains the text "This is a &ltTest String&gt.", and copies it into the string named DecodedString as "This is a <Test String>."

[Visual Basic] 
Dim EncodedString As String = "This is a &ltTest String&gt."
Dim writer As New StringWriter
Server.HtmlDecode(EncodedString, writer)
Dim DecodedString As String = writer.ToString()

String EncodedString = "This is a &ltTest String&gt.";
StringWriter writer = new StringWriter();
Server.HtmlDecode(EncodedString, writer);
String DecodedString = writer.ToString();

String* EncodedString = S"This is a &ltTest String&gt.";
StringWriter* writer = new StringWriter();
Server->HtmlDecode(EncodedString, writer);
String* DecodedString = writer->ToString();

var encodedString : String = "This is a &ltTest String&gt."
var writer : StringWriter = new StringWriter()
Server.HtmlDecode(encodedString, writer)
var decodedString : String = writer.ToString()


Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family

See Also

HttpServerUtility Class | HttpServerUtility Members | System.Web Namespace | HttpServerUtility.HtmlDecode Overload List