1

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.

rf_wilson
  • 1,562
  • 5
  • 32
  • 44
  • 1
    If you have the project, and therefore the source, why do you need to manually bind the debugger at all? – Grant Thomas Mar 04 '13 at 13:41
  • Because the site is part of a content management solution, which entails that I need to be logged in. I prefer to use my existing web browser session otherwise I have to jump through many more steps to get the part I want to debug. You mark me down for that? Nice. – rf_wilson Mar 04 '13 at 13:43
  • Sorry Grant - i was being presumptuous – rf_wilson Mar 04 '13 at 13:48

3 Answers3

2

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.

rf_wilson
  • 1,562
  • 5
  • 32
  • 44
  • They all work this way. You'll notice that changing something in an aspx page and saving and setting a breakpoint will cause the 'error' breakpoint symbol, when you refresh the page _then_ you can see all of the symbols being loaded. – Grant Thomas Mar 04 '13 at 17:52
0

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

Rune FS
  • 21,497
  • 7
  • 62
  • 96
0

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

dev123
  • 31
  • 1
  • 7