Malformed web.config causing a Parser Error

“Server Error in ‘/’ Application” or “Parser Error” – it’s actually a malformed web.config killing your ASP.NET-application or SharePoint

This post was most recently updated on September 30th, 2022.

2 min read.

This post describes how to resolve a kind of cryptic and oddly misdescriptive error message about Parser Error on your ASP.NET application or (an On-Premises) SharePoint site. I ran into this after deploying wsp-packages to a SharePoint farm, but you can apparently get this on ASP.NET MVC sites, too.

The error doesn’t actually tell you what’s wrong, so figuring it out took a while. Though hopefully, it helps you!

Symptoms: Parser Error from a random-looking location

Once you navigate to your web- or SharePoint site, you only get an error like this:

Server Error in ‘/’ Application.

Parser Error

Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: Index was outside the bounds of the array.

The next few rows (the actual source of the error) seem to vary wildly. The exact source depends on what went wrong in the parsing or the latest deployments. In any case, they’re usually something like this:

Parser Error
Line 3: <WebControls:XmlUrlDataSource runat="server" AuthType="None" HttpMethod="GET"> 
Line 4:  <DataFileParameters> 
Line 5:   <WebPartPages:DataFormParameter Name="RequestUrl" ParameterKey="RequestUrl" PropertyName="ParameterValues"/> 
Line 6:  </DataFileParameters> 
Line 7: </WebControls:XmlUrlDataSource>

Okay, that doesn’t tell us that much! So how to get rid of it?

Solution

Most likely a wsp deploy or something else has resulted in a malformed web.config file. Redeploying did not fix this for me (it could have), nor did it reset, but recycling the application pool in question did. Surprisingly.

So, there you go! Recycle the application pool, and if that does not help, go through your web.config files and see if you can figure if something’s wrong with them.

mm
4 1 vote
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments