What is the difference between HttpUtility.HtmlEncode and Server.HTMLEncode?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
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.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0