The web.config is invalid on this IIS Web Site

When you unextend a web application via Central Admin or Stsadm.exe –o UnextendVs on a SharePoint 2007 farm, you may see this message in the SharePoint Trace Logs:






Windows SharePoint Services




Solution Deployment : Error occurred for solution MySolution.wsp - Error: The web.config is invalid on this IIS Web Site: C:\inetpub\wwwroot\wss\VirtualDirectories\MyExtendedWebApp80\web.config.

You get this error when you have a Web Application scoped solution that is deployed to the Web Application that modifies the web.config.  For example, a solution that has a SafeControl entry.  When SharePoint unextends the Web Application, the IIS web site is cleaned up first, then the solutions are retracted.  This results in the web.config being cleaned up prior to the solution trying to remove its changes.

The error doesn’t cause anything to stop processing.  The remaining components of the solution are processed along with remaining solutions deployed to the Web Application, so you can ignore the message in this particular scenario.