views:

762

answers:

4

I have set a breakpoint in an HTTPHandler in visual studio. The HTTPHandler is an .ashx file I am trying to debug by running my application in the VS development web server. My breakpoint is NOT getting hit.

How can I step through it?

EDIT: My breakpoint is NOT getting hit

A: 

In Visual Studio, Check out the Debug menu. In there you will find Step Into, Step Over etc, and depending on your keyboard binding you can typically hit F10.

David Christiansen
A: 

Try do debug using the built in web server instead of the local IIS (or vice-versa if you're using the local IIS). There are minor differences between the two web servers.

Jan Aagaard
+2  A: 

Open the handler file in Visual Studio and place the breakpoint as you said. Then load the web application in your browser (starting your application in debug-mode of course). If the breakpoint remains gray and doesn't turn filled black, then your handler is probably not registered appropriately in your webapp. That's mostly the issue. If according to you everything is fine, try doing a clean + rebuild of your entire solution. Often that helps already.

Juri
How do you register the handler? I didn't think you had to register *.ashx files.
Ronnie Overby
see this to learn how to register handlers http://msdn.microsoft.com/en-us/library/46c5ddfy(VS.80).aspx
MOZILLA
That's what I intended. Probably it isn't registered correctly and therefore you breakpoint is never hit.
Juri
A: 

I had this problem and it turns out that the ashx file didn't compile. I guess they get compiled at runtime because I didn't get a compile error until then. Additionally I wasn't seeing the Yellow Screen of Death indicating an HttpCompileException because:

  • I originally intended to fix a bug in the asxh file.
  • I made changes to the file to fix the bug, in which I unknowingly introduced a compile error.
  • I tested the bug fix, got the all purpose friendly exception I had configured in custom errors.
  • I assumed it was the same bug I had gone into fix because I couldn't see the true exception a la Yellow Screen of Death and didn't bother checking ELMAH
  • I set a breakpoint, and couldn't figure out why it wasn't being hit.

Eventually I did see the newly introduced exception, fixed the compile error, and now the breakpoint is being hit like it should, although it doesn't light up when the debugger is initially launched, rather when the handler is invoked (by an AJAX call in my case).

I Have the Hat