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 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. Hopefully it’ll help you, though!

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 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’ve), nor did iisreset, 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 in them.

The following two tabs change content below.

Antti K. Koskela

Solutions Architect / Escalations Engineer at Koskila / Norppandalotti Software / Valo Solutions
Antti Koskela is a proud digital native nomadic millenial full stack developer (is that enough funny buzzwords? That's definitely enough funny buzzwords!), who works as a Solutions Architect for Valo Intranet, the product that will make you fall in love with your intranet. Working with the global partner network, he's responsible for the success of Valo deployments happening all around the world. He's been a developer from 2004 (starting with PHP and Java), and he's been bending and twisting SharePoint into different shapes since MOSS. Nowadays he's not only working on SharePoint, but also on .NET projects, Azure, Office 365 and a lot of other stuff. This is his personal professional (e.g. professional, but definitely personal) blog.

Let me know your thoughts!