我尝试使用htmleditorextender,但出现错误。以下是我的设置
<%@ 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>
我的web.conf设置是;
<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>
我的bin文件夹中有以下dll;
AntiXSSLibrary.dll
SanitizerProviders.dll
HtmlSanitizationLibrary.dll
但我仍然会收到此错误;
Could not load type 'AjaxControlToolkit.Sanitizer.AntiXssSanitizerProvider'.
为什么会出现此错误?
最佳答案
截至2012年6月,将AntiXss
用作默认的 sanitizer 是no longer supported。从官方公告来看,新版本的AntiXss
显然破坏了很多事情。
要将AjaxControlToolkit与HTML Agility Pack
一起使用,您首先需要使用Nuget(instruction)安装pacakge。
然后,您可以像这样修改HTML Agility Pack
,将web.config
用作 sanitizer :
<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>
希望这可以帮助。
关于c# - 无法加载类型 'AjaxControlToolkit.Sanitizer.AntiXssSanitizerProvider'。,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/12022493/