How to change .NET HTML encoding
.NET Framework 4.0 or later, able to change .NET HTML encoding By httpRuntime attribute in web.config.
httpRuntime has a attribute to change HttpEncoder type. This attribute is "encoderType".
To customize encoding, set a class that inherits from HttpEncoder class.
web.config setting
< httpRuntime encoderType="WebApplication1.CustomHttpEncoder"/>
customized class
namespace WebApplication1
public class CustomHttpEncoder : System.Web.Util.HttpEncoder
{
protected override void HtmlAttributeEncode(string value, System.IO.TextWriter output)
{
//Write custom behavior ( Attribute behavior)
}
protected override void HtmlEncode(string value, System.IO.TextWriter output)
{
//Write custom behavior ( Element behavior)
}
}
Written by Shin-ichi Hashiba
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Asp.net
Authors
Related Tags
#asp.net
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#