Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is debugattach.aspx and why can't the server find it?

I'm developing on an XP (SP3) machine with VS 2010 and IIS 5.

I have two versions of the same site. We've released our first production version, so I forked the code into a new directory tree, and set up new virtual directories in IIS to point to the new trees. The projects are set up to run in the IIS rather than VS's server. The main site is an MVC 2 based project.

My problem is that, when I hit F5 in Visual Studio 2010 to begin debugging the new version, I get a "Unable to start debugging on the Web Server. The web server could not find the requested resource." I spent the better part of yesterday trying to figure out what resource it was looking for that it couldn't find. This occurs before it ever gets to "Application Start". I finally thought of looking in the Web logs, and found that whenever I hit the F5 key, the web log shows a DEBUG request for /debugattach.aspx, with a return code of 404 (not found). If I run the same sequence on the old version, it shows the same thing, but first with a 401 code, and then the request repeated with a 200 code.

My first thought was that VS must be writing out a "debugattach.aspx" file, and then invoking it, and maybe it doesn't have write permission to the directory, but, as far as I can tell, it does.

I've googled debugattach.aspx, and the first several pages of articles that are returned all seem to refer to lockup's and timeouts, mostly on IIS 7 and VS 2005. Nothing that seems to apply to this situation.

Looking at what's different between the old version that works and the new version that doesn't, the only things are the IIS setup of the virtual directories, and the web.config on the code itself. But I've gone over the two sites side by side, and can't find any differences that account for this behavior.

Does anybody have a clue they can share with me? Or can anyone point me to any documentation on what exactly debugattach.aspx is/does, and what a DEBUG HTTP request does, and/or how VS uses them?

Thanks in advance.

like image 378
Dave Hanna Avatar asked Dec 17 '10 13:12

Dave Hanna


2 Answers

For performance reasons we removed all the handlers from the <system.webServer> element of our MVC 5 project's web.config except for StaticFile and ExtensionlessUrlHandler-Integrated-4.0, and then started getting this error when debugging from Visual Studio.

After some investigation, we discovered that in normal use, whatever module that handles this request simply causes HTTP error 401 (unauthorized) to be returned. I was not able to find out exactly which module it was, but I was able to find the class that is responsible: System.Web.HttpDebugHandler.

Therefore, we added the following line into our web.config handlers:

<add name="DebugAttachHandler" path="DebugAttach.aspx" verb="DEBUG"
    type="System.Web.HttpDebugHandler" resourceType="Unspecified" requireAccess="Script"
    preCondition="integratedMode,runtimeVersionv4.0" responseBufferLimit="0" />

When that URL is hit, IIS gives out a 401 just as when all handlers are enabled, so Visual Studio is happy again.

See also: https://developercommunity.visualstudio.com/content/problem/464980/unable-to-start-debugging-a-web-project-when-vs-ge.html

like image 148
Ian Kemp Avatar answered Oct 06 '22 00:10

Ian Kemp


In my case I had created an Empty Web Application with VS2017 on Windows 10. When I unchecked the box for ASP.NET Debugger under Project Settings -> Web the problem went away. Before that I tried almost every suggestion out there to resolve the problem.

like image 36
J Cox Avatar answered Oct 06 '22 00:10

J Cox