Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why can't I set a breakpoint in a ASP.NET view?

If I set a breakpoint in the compiled code (for instance in an action), I can then step through, and eventually am stepping through the generation of the View.

I've found this useful a couple of times, but it's tedious as you have to step through a lot of code to get there.

However, I can't set a breakpoint in view. I just receive the message 'This is not a valid location for a breakpoint' from VS2008. Why is this?

like image 378
UpTheCreek Avatar asked Jan 05 '11 10:01

UpTheCreek


People also ask

Why are my breakpoints not working?

If a source file has changed and the source no longer matches the code you're debugging, the debugger won't set breakpoints in the code by default. Normally, this problem happens when a source file is changed, but the source code wasn't rebuilt. To fix this issue, rebuild the project.

How do I enable breakpoints?

To set a breakpoint in source code: Click in the far left margin next to a line of code. You can also select the line and press F9, select Debug > Toggle Breakpoint, or right-click and select Breakpoint > Insert breakpoint. The breakpoint appears as a red dot in the left margin.

How do I add a data breakpoint in Visual Studio?

To set a data breakpoint: In a C++ project, start debugging, and wait until a breakpoint is reached. On the Debug menu, choose New Breakpoint > Data Breakpoint.


2 Answers

Right click on the code you want to break on and go to "Breakpoint -> Insert Breakpoint".

Why? Must have something to do with the face your not working with a pure code file and hitting the left sidebar doesn't know which block of code to use.

like image 194
John Farrell Avatar answered Oct 13 '22 21:10

John Farrell


Another thing that comes to my mind is to use the debugger; keyword in the view, though I am not 100% sure it will work as in ASP.NET ajax site.

like image 42
Dick Lampard Avatar answered Oct 13 '22 22:10

Dick Lampard