Search code examples
c#html-encode

C# WebUtility.HtmlEncode at .NET 3.0


I'm making an (form) application, with the possibility to send a notification mail.

On my application there are two variables, that will be placed into the html body of the mail. One of them is a number, but the second is a name, which can contain the < and > characters.

I found an useful function to encode this, but the System.Net.WebUtility.HtmlEncode(String); only works on .NET 4.0, while my app is programmed in .NET 3.0.

Is there a simple function to replace the System.Net.WebUtility.HtmlEncode(String); which works in .NET 3.0?


Solution

  • System.Web.HttpUtility.HtmlEncode exists from 1.1