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!

Comments

  • Anonymous
    March 23, 2009
    What if removing the location tag is not an option?  I have this exact problem, but I need the location tag present in order for a subdirectory to function correctly: <location path="." inheritInChildApplications="false">Is there any other work-around to allow debugging on the root site while still allowing the presence of the location tag?
  • Anonymous
    May 19, 2009
    I have the same issue as Chris-- removing the location tag is not an option as that is the only way a subdirectory application will work.  Very frustrating!!
  • Anonymous
    May 19, 2009
    Chris and Peter, Unfortunately there is no work around to this at the moment. But it might get fixed in next version.
  • Anonymous
    October 02, 2009
    I had this issue and I uninstalled my IE 8 - and used IE7 version - Now I am able to debug thru Visual Studio.Priya
  • Anonymous
    October 28, 2010
    This is incredibly annoying. I can remove the location tag in development as I don't need the subdirectories to work locally, but when pushing to production its a pain.
  • Anonymous
    May 25, 2011
    The comment has been removed