.NET Framework Class Library
HttpServerUtility..::.HtmlEncode Method

Encodes a string to be displayed in a browser.

Overload List

  NameDescription
Public methodHtmlEncode(String)HTML-encodes a string and returns the encoded string.
Public methodHtmlEncode(String, TextWriter)HTML-encodes a string and sends the resulting output to a TextWriter output stream.
Top
See Also

Reference

Tags :


Community Content

Thomas Lee
HttpUtility, NOT HttpServerUtility
Its actually the System.Web.HttpUtility that has the HtmlEncode method, not the HttpServerUtility class.
Tags : contentbug

Thomas Lee
MS, please correct this
Microsoft, can you update this? He's right. Your doc is wrong.
Tags : contentbug

tamer yousef
yup, they are right, microsoft doc is wrong!!
fix your stuff!
Tags :

Jaap Vossers
microsoft is right

BOTH HttpServerUtility and HttpUtility expose an HtmlEncode() method

the difference is that HttpUtility is the only class that exposes it as a STATIC method.

HttpServerUtility exposes it as a non-static method. You can grab an instance of HttpServerUtility from HttpContext.Current.Server in a web context.

Tags :

Page view tracker