Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jan 21, 2013 09:40 AM by enewmen
Aug 08, 2012 04:03 PM|LINK
I am having trouble with adding the required text to the web.config file for the HtmlAgilityPackSanitizerProvider.
Even when I open the sample site from the toolkit in Visual Web Developer I get an error.
The element 'system.web' has an invalid child element 'sanitizer'.
Not sure how to get this to work.
This is the section of the toolkit sample site:
<section name="sanitizer" requirePermission="false"
type="AjaxControlToolkit.Sanitizer.ProviderSanitizerSection, AjaxControlToolkit" />
<trust level="Full" />
<add name="HtmlAgilityPackSanitizerProvider" type="AjaxControlToolkit.Sanitizer.HtmlAgilityPackSanitizerProvider"></add>
Aug 08, 2012 07:35 PM|LINK
I am also having this exact problem along with TonyLoco23 (on another post). This question is asked a lot in forums, but I have never found it answered.
The whole error is:
Warning 1 The element 'system.web' has invalid child element 'sanitizer'. List of possible elements expected: 'anonymousIdentification, authentication, authorization, browserCaps, clientTarget, compilation, customErrors, deployment, deviceFilters, fullTrustAssemblies,
globalization, healthMonitoring, hostingEnvironment, httpCookies, httpHandlers, httpModules, httpRuntime, identity, machineKey, membership, mobileControls, pages, partialTrustVisibleAssemblies, processModel, profile, roleManager, securityPolicy, sessionPageState,
sessionState, siteMap, trace, trust, urlMappings, webControls, webParts, webServices, xhtmlConformance, caching'. http://localhost/web.config 11 6
And, as far as I can see, the people asking the questions post clean code that is easy to read, and the people attempting to answer them post cryptic code like they do not know how to cut and paste without the <div> garbage.
Here is another thread with the same issue that goes unanswered:
So far, I have built three different virtual machines (windows 7 on my work laptop, windows 7 on my home computer, windows server 2k8 r2 on my home computer) and I get the same exact issue every time whether it is HtmlAgilityPackSanitizerProvider or AntiXssSanitizerProvider.
That, and the fact that this question gets asked a lot, tells me that there might either be some new 'bug' or some assumed configuration change that old developers automatically know and new asp.net developers do not.
I get this error attempting to follow Stephen Walther's blog post here:
Can this be explained like I am 5?
Aug 09, 2012 03:12 AM|LINK
The <system.web> element section group definition isn't valid because the system web section group uses a type, which means it has an explicit definition. You can't include your custom config section in the <system.web>; put it in your own sectionGroup
or at the root level instead. You don't need to define a sectionGroup type, but can just simply use a name to group your custom sections.
Aug 09, 2012 11:25 AM|LINK
It is not my config file, it is the sample one provided with the toolkit.
The sectionGroup part goes in the the configuration section and works OK. It is the sanitizer part that is the problem. It does not work in system.web and as a new asp.net coder I and apparently a lot of others have no idea where to put the
This gives the invalid child element error and I have no idea what to do about that.
Aug 10, 2012 03:22 AM|LINK
This is an existing issue with the toolkit. I see you've created a track at
For a walkaround, you can also use this library to sanitize the user's input at code behind,
Aug 13, 2012 12:43 PM|LINK
I used NuGet to add the HtmlAgilityPack as you suggested but I STILL get the same error in the web.config file.
Here are the steps to duplicate the error: download the tookit. Unzip the sample web site. Open the web.config file. The sanitizer is marked as an invalid child node in the config file.
Nov 29, 2012 04:59 PM|LINK
I have the same problem. I have HTMLAgilitypack.dll in the Bin folder but when I add the required sections to the config file I get this:
An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: Unrecognized element 'sanitizer'.
Line 63: <compilation debug="true" strict="false" explicit="true" targetFramework="4.0">
Line 64: <!-- Sanitizes for the HTML Editor Extender -->
Line 65: <sanitizer defaultProvider="HtmlAgilityPackSanitizerProvider"> Line 66: <providers>
Line 67: <add name="HtmlAgilityPackSanitizerProvider" type="AjaxControlToolkit.Sanitizer.HtmlAgilityPackSanitizerProvider"></add>
Has this issue been resolved?
Jan 21, 2013 09:40 AM|LINK
I have the same issue as well.
'system.web' has an invalid child element 'sanitizer'.
Using Visual Studio 12/ .Net 4.5 - I updated AjaxControlToolKit 4.1.60919.0, HtmlAgilityPack 22.214.171.124, SanitizerProviders 126.96.36.199 using GuNET and installing using Package Manager Console. Newest and updated everything.
What else can be done? I hope this thread re-opens.