What is the difference between HttpUtility.HtmlEncode
and Server.HTMLEncode
?
Asked
Active
Viewed 1.4k times
13

Alexei Levenkov
- 98,904
- 14
- 127
- 179

GibboK
- 71,848
- 143
- 435
- 658
-
For .Net core See https://stackoverflow.com/questions/17352981/webutility-htmldecode-vs-httputilty-htmldecode – Michael Freidgeim May 14 '21 at 20:40
1 Answers
15
Have a look at Server.HtmlEncode vs HttpUtility.HtmlEncode .
Basically, Server.HtmlEncode
uses a specific instance of the System.Web.HttpServerUtility
class that's inherited from the Page
class. HttpUtility.HtmlEncode
is a static method, so you don't have to instantiate the HttpUtility
class.
All else being equal, go with the static HttpUtility.HtmlEncode
.

Alexei Levenkov
- 98,904
- 14
- 127
- 179

Adriaan Stander
- 162,879
- 31
- 289
- 284