ASP Parser Error

More “dreaded” errors in SharePoint. We started receiving the this fun error when loading one of our portals:

Server Error in ‘/’ Application.
Runtime Error
Description: An application error occurred on the server.[…]

We hadn’t recently patched, or performed any updates except for increasing the max allowed upload file size and timeouts (a client needed to upload LARGE files). The server application logs revealed something slightly more useful:

Event Type: Warning
Event Source: ASP.NET 2.0.50727.0
Event Category: Web Event
Event ID: 1310
Date: 5/6/2010
Time: 4:50:11 PM
User: N/A
Computer: ServerName
Event code: 3006
Event message: A parser error has occurred.
Event time: 5/6/2010 4:50:11 PM
Event time (UTC): 5/6/2010 8:50:11 PM
Event ID: 57cbaa6a1f804cb2aefe80de4ceec102
Event sequence: 5
Event occurrence: 1
Event detail code: 0

Application information:
Application domain: /LM/W3SVC/1965610693/Root-1-129176526056583668
Trust level: WSS_Minimal
Application Virtual Path: /
Application Path: C:\Inetpub\wwwroot\wss\VirtualDirectories\foldername443\
Machine name: ServerName

Process information:
Process ID: 1944
Process name: w3wp.exe

Exception information:
Exception type: HttpParseException
Exception message: Could not load file or assembly ‘System?Web, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’ or one of its dependencies. The system cannot find the file specified. (C:\Inetpub\wwwroot\wss\VirtualDirectories\foldername443\web.config line 106)

Now, the web.config wasn’t manually edited by anyone, but the modified date matched the date & time when this problem started as well as the beginning of these ASP.NET errors. All the evidence seemed to point to what I can only assume was caused by a hiccup when the settings were being saved from IIS – that corrupted the web.config.

I found 4 or 5 randomly placed “?” in the web.config. I couldn’t just remove the question marks because they appeared to have replaced characters in the file instead of being inserted. I didn’t have a backup, but we did have multiple AAMs for this portal and I was able to look at another web.config. This gave me a better idea of what characters should have been in the file wherever I wasn’t able to make a good educated guess.