C#: Can't debug ASHX handler

僤鯓⒐⒋嵵緔 提交于 2019-12-13 01:44:52

问题


I have an ASP.net C# 4.0 website project. I am calling an ASHX handler using a jQuery AJAX postback. Normally when I debug C#, I use this method Debug > Attach to Process > select w3wp.exe and start debugging.

When I do this with my ASHX handler Visual Studio says "The breakpoint will not be hit. No symbols have been loaded for this document." Sure enough, when I run the AJAX call to the handler, the breakpoint is not hit.

What confuses me is that I can debug C# files otherwise, i.e. the code-behind of an ASPX file.


回答1:


It turns out that Visual Studio will not actually load symbols for debugging until it actually tries to run the ASHX handler. My problem turned out to be elsewhere - a bug in the jQuery code that called the handler.

I didn't see this bug at first so assumed the handler was being hit. Once the handler is called, VS will then allow you to debug it. I didn't realise that ASHX handlers behaved this way, I thought they would work just like a regular C# file.




回答2:


This is generally because what you are looking at (the code) is not what you are running.

Try to throw in Debugger.Launch(); and see if that attaches the debugger correctly. If it does then your problem is simply that you are view a different copy/version of the code that's unrelated to the debugging




回答3:


Is there only one w3wp.exe try right clicking your asp.net project select "Debug" and "Start a new instance" from context menu.



来源:https://stackoverflow.com/questions/15202903/c-cant-debug-ashx-handler

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!