In this article I will explain how to solve the error (exception) occurring when using the AJAX Control Toolkit’s HtmlEditorExtender control in ASP.Net.
Sanitizer provider is not configured in the web.config file. If you are using the HtmlEditorExtender with a public website then please configure a Sanitizer provider. Otherwise, set the EnableSanitization property to false.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
 
Error
Sanitizer provider is not configured in the web.config file. If you are using the HtmlEditorExtender with a public website then please configure a Sanitizer provider. Otherwise, set the EnableSanitization property to false.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Exception: Sanitizer provider is not configured in the web.config file. If you are using the HtmlEditorExtender with a public website then please configure a Sanitizer provider. Otherwise, set the EnableSanitization property to false.
 
 
What is Sanitization?
Sanitization is a generic term related to cleaning. When we enable Sanitization, HtmlEditorExtender will remove all malicious tags and thus will prevent Cross Site Scripting attacks.
 
Solutions
Disable Sanitization
If you don’t need this security feature, you can simply set EnableSanitization property to False.
<asp:HtmlEditorExtender ID="HtmlEditorExtender1" runat="server" TargetControlID="txtEditor" EnableSanitization="false">
</asp:HtmlEditorExtender>
 
Configure Sanitization
If you want to use the Sanitization feature in HtmlEditorExtender then you will need to do some configurations as shown in the steps below.
1. You will need to download the HtmlAgilityPack.dll from the following download location.
2. Once downloaded, you will need to place the HtmlAgilityPack.dll in the BIN folder of your website project and add its reference to the project as shown below.
AJAX Control Toolkit HtmlEditorExtender: Sanitizer provider is not configured in the Web.Config file
3. Next you need add the following Section in the ConfigSections tag of the Web.Config file.
<configSections>
    <sectionGroup name="system.web">
        <section name="sanitizer" requirePermission="false"
                    type="AjaxControlToolkit.Sanitizer.ProviderSanitizerSection, AjaxControlToolkit" />
    </sectionGroup>
</configSections>
 
4. Finally you need to place the following Sanitizer tag in the System.Web section of the Web.Config file.
<sanitizer defaultProvider="HtmlAgilityPackSanitizerProvider">
    <providers>
        <add name="HtmlAgilityPackSanitizerProvider" type="AjaxControlToolkit.Sanitizer.HtmlAgilityPackSanitizerProvider"></add>
    </providers>
</sanitizer>
 
After completion of the above steps, the Web.Config file should look as below.
<?xml version="1.0"?>
<configuration>
    <configSections>
        <sectionGroup name="system.web">
            <section name="sanitizer" requirePermission="false"
                        type="AjaxControlToolkit.Sanitizer.ProviderSanitizerSection, AjaxControlToolkit" />
        </sectionGroup>
    </configSections>
    <system.web>
        <compilation debug="true" targetFramework="4.0">
            <assemblies>
                <add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
                <add assembly="System.Web.Extensions.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
                <add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
            </assemblies>
        </compilation>
        <sanitizer defaultProvider="HtmlAgilityPackSanitizerProvider">
            <providers>
                <add name="HtmlAgilityPackSanitizerProvider" type="AjaxControlToolkit.Sanitizer.HtmlAgilityPackSanitizerProvider"></add>
            </providers>
        </sanitizer>
    </system.web>
</configuration>
 
That’s all you need to do to get rid of the Sanitization exception occurring when using the AJAX Control Toolkit’s HtmlEditorExtender control in ASP.Net.