Resolving error of “is an unexpected token. The expected token is xx or xx . Line xx ,Position xx for Sharepoint 2007

This is a very generic error  fired by .net xml parsers System.Xml.XmlException. In our scenario this error has occured when we tried to change authentication providers for a site.

Usually this error is cuased by a missing charecter or illegal charecter usage in xml files. You know we have so many configuration file in sharepoint. Basic and first look place is that the Web.Config file. Notice that the line and position values and check your web.config file any problem on this location.

For our scenario the Problem Found on 23, 109 the double quots are not supported type for includesubfolders attribute

<PageParserPath VirtualPath=”/*” CompilationMode=”Always” AllowServerSideScript=”true” IncludeSubFolders=true />

So the error has fired once sharepoint try modification to web.config for update the authentication providers. So the error source is important to define which configuration file that you have to check.




Disable stop deny web.config inheritance

I find a good article about Configuration Inheritance below:

Each ASP.NET Web Application has its own configuration file called web.config file. 
In fact every directory in ASP.NET application can have one. Settings in each web.config file apply to the pages in the directory where its placed, and all the subdirectories of that directory.This is called 

Configuration Inheritance. 

So if you create an ASP.NET application and set its web.config file, add custom HttpHandlers, UrlRewriting module etc and try to create another ASP.NET Web Application in the subfolder, you can end up having problems because application in the subfolder will inherit all the settings from its parent  web.config.

So if you for example setup UrlRewriter module in your root web applications like this:


        <add name=”UrlRewriteModule” type=”UrlRewritingNet.Web.UrlRewriteModule, UrlRewritingNet.UrlRewriter”/>

        <add name=”ScriptModule” type=”System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35″/>


And in your child web application (in subfolder) you are not using UrlRewriteModule, then if you try to run the child Web Application in your browser, you will get error like this:

Configuration Error

Description: 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. 
Line 88: <httpModules>
Line 89:   <add name="UrlRewriteModule" type="UrlRewritingNet.Web.UrlRewriteModule, UrlRewritingNet.UrlRewriter"/>
Line 90:   <add name="ScriptModule" type="System.Web.Handlers.ScriptModule,
          System.Web.Extensions, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
Line 91: </httpModules>

Luckily, there is a easy solution to this problem.

Source Error: 
What happens here is that because UrlRewriteModule is configured in the parent’s folder web.config file, this setting is inherited by the child application’s web.config file, and because of this ASP.NET is looking for the UrlRewriteModule DLL file in the BIN directory, and off course its not there.

First thing you can do is to remove the problematic HttpModule in your child application web.config file using the removecommand like this:


        <remove name=”UrlRewriteModule” />


This would remove the handler and your application would run fine.
Or you could use <clear/> command like this:




This would clear all the HttpModules in your child application.

But what to do when there are many settings in your root web.config file that you don’t want to be propagated to your child applications?

Here is the solution:
With the <location> attribute with inheritInChildApplications set to false in your root web.config file you can restrict configuration inheritance. 
So, by wrapping a section of your web.config file in <location> attribute you can instruct ASP.NET not to inherit those settings to child applications/folders and their web.config files.

In fact  you can wrap the whole <system.web> section in one <location> attribute and disable configuration inheritance so none of the parent settings from <system.web> will be inherited to the child applications you create in subfolders.

Here is how to use this in practice:

  <location path=”.” inheritInChildApplications=”false”>



NOTE: Do remember that if you do this, you need to manually insert all the settings you need in the <system.web> for your child applications because none of the settings from the root web.config will be propagated…