I want to converter all special characters into Html encoded characters.
I found many post related to used HttpUtility.HtmlEncode();
,
but it\'s only convert so
you can also do as follows without AntiXSS
public static string HtmlEncode (string text)
{
string result;
using (StringWriter sw = new StringWriter())
{
var x = new HtmlTextWriter(sw);
x.WriteEncodedText(text);
result = sw.ToString();
}
return result;
}
Yes.Using javascript Escape them.
document.write(escape("3423424242<><><$$"));
The Microsoft AntiXss Library can accomplish this;
string p = Microsoft.Security.Application.Encoder.HtmlEncode("aaa <b>sdf</b> š,Ø,þ,›,Ù", true);
Response.Write(p);
For
aaa <b>sdf</b> š,Ø,þ,›,Ù