<location> Tag Causes Local Automatic ASP.NET debugging not to work in Visual Studio

This week I got an interesting issue altogether. One of my customers was unable to debug ASP.NET 3.5 application locally using Visual Studio 2008. The application was created using Web Application Project. When we started the application using "Start Debugging (F5)", page came up fine but debugger was not getting attached to process. In Visual Studio we could still see the "Play" button for starting debugging. We didn't get any errors either in Visual Studio or in Event Logs. At the same time when we try attaching the Visual Studio debugger manually then it worked fine.

We confirmed the current user has all the required permissions and is admin on the machine. We went through all the possibilities as per KB - "INFO: Common Errors When You Debug ASP.NET Applications in Visual Studio .NET" but no luck.

When we checked configuration carefully found that the <compilation debug="true" /> Tag was encapsulated within <location path="." allowOverride="true">, like below code snippet -

 <?xml version="1.0"?>
<configuration>
    <appSettings/>
    <connectionStrings/>
    <location path="." allowOverride="true" >
      <system.web>
          <compilation debug="true">
          </compilation>
          <authentication mode="Windows" />
      </system.web>
    </location>
</configuration>

We tried removing location tag as that was the only thing suspicious here and it started working!!!

So I did some research and found that this is something consistent across all the Visual Studio Versions Supported (2003, 2005 and 2008) when we use the Web Application Project. Basically placing a <system.web><compilation debug="true" /></system.web> setting inside a <location path="."> tag is correctly interpreted by ASP.NET, but Visual Studio thinks that the web.config isn't set up for debugging.

When we try the same web.config with Web Site in Visual Studio 2005 or 2008 it gives up dialogue -

untitled

So to get around this situation we need to remove the location tag from web.config.

I hope this help!