What is the difference between HttpUtility.HtmlEncode and Server.HTMLEncode?
HttpUtility.HtmlEncode
Server.HTMLEncode
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.
Server.HtmlEncode
System.Web.HttpServerUtility
Page
HttpUtility
All else being equal, go with the static HttpUtility.HtmlEncode.
2.1m questions
2.1m answers
60 comments
57.0k users