Could not load type 'AjaxControlToolkit.Sanitizer.AntiXssSanitizerProvider'.
Asked Answered
D

4

5

I tried to use htmleditorextender but I am getting error. below are my settings

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>

<asp:TextBox runat="server" ID="textBoxGalleryUrl" CssClass="cstmtxtclr" />
<asp:HtmlEditorExtender ID="HtmlEditorExtender1" runat="server" TargetControlID="textBoxGalleryUrl"></asp:HtmlEditorExtender>

My web.conf settings are;

  <configSections>
    <sectionGroup name="system.web">
      <section name="sanitizer"
          requirePermission="false"
          type="AjaxControlToolkit.Sanitizer.ProviderSanitizerSection, AjaxControlToolkit"/>
    </sectionGroup>
  </configSections>

  <system.web>
    <!--<httpRuntime requestValidationMode="2.0"/>-->
    <compilation debug="true" targetFramework="4.0"/>

    <sanitizer defaultProvider="AntiXssSanitizerProvider">
      <providers>
        <add name="AntiXssSanitizerProvider"
              type="AjaxControlToolkit.Sanitizer.AntiXssSanitizerProvider"></add>
      </providers>
    </sanitizer>
  </system.web>

I have the following dlls in my bin folder;

AntiXSSLibrary.dll
SanitizerProviders.dll
HtmlSanitizationLibrary.dll

But I still get this error;

Could not load type 'AjaxControlToolkit.Sanitizer.AntiXssSanitizerProvider'.

Why I am getting this error?

Dogy answered 18/8, 2012 at 21:47 Comment(1)
Try the solution offered by Bertzzie in #12022993 . It Works for me.Chablis
P
14

Using AntiXss as the default sanitizer is no longer supported as of June 2012. From the official announcement, apparantely the new version of AntiXss breaks too many things.

To use AjaxControlToolkit with HTML Agility Pack you first need to install the pacakge using Nuget (instruction).

Then you can use HTML Agility Pack as your sanitizer by modifying your web.config like this:

<configuration>
    <configSections>
        <sectionGroup name="system.web">
            <section name="sanitizer" requirePermission="false"
                     type="AjaxControlToolkit.Sanitizer.ProviderSanitizerSection, AjaxControlToolkit" />
        </sectionGroup>
    </configSections>

    <system.web>
        <sanitizer defaultProvider="HtmlAgilityPackSanitizerProvider">
            <providers>
                <add name="HtmlAgilityPackSanitizerProvider" type="AjaxControlToolkit.Sanitizer.HtmlAgilityPackSanitizerProvider"></add>
            </providers>
        </sanitizer>
      </system.web>
</configuration>

Hope this helps.

Presentational answered 20/8, 2012 at 13:24 Comment(3)
I tried but I m getting this -> Could not load file or assembly 'HtmlAgilityPack, Version=1.4.0.0, Culture=neutral, PublicKeyToken=bd319b19eaf3b43a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)Dogy
Have you installed the HTML Agility Pack from Nuget? I did remember installing that first, and I don't have to setup anything...Presentational
i am using this but it doesn't even remove <script>alert('asdas')</script> @MikeKingscottKary
C
2

HTML Agility Pack must be installed for all new versions of Ajax Control Toolkit. Unfortunetly a lot of answers in the web are wrong

Crosier answered 9/12, 2012 at 14:56 Comment(0)
W
1

Having searched high and low for the same problem to be solved, I worked out that the Ajax Control Kit also needed to be loaded via the Library Package Manager...

PM > Install-Package AjaxControlToolkit

This solved the problem for me.

Wellfounded answered 6/12, 2012 at 9:23 Comment(0)
N
0

It's recommended that you download the latest Html Agility Pack from here : http://htmlagilitypack.codeplex.com/ and place in your bin and add reference to it in your project.

Or use the install command :

PM> Install-Package HtmlAgilityPack

you may look at this link http://nuget.org/packages/HtmlAgilityPack

You don't have to use or reference to AntiXSSLibrary just use the HtmlAgilityPackSanitizerProvider and your error will disappear

Good luck

Nymphet answered 25/1, 2013 at 5:44 Comment(1)
hsobhy how do i use only htmlagilitypacksanitizerprovider can you explain ?Kary

© 2022 - 2024 — McMap. All rights reserved.