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

馋奶兔 提交于 2019-12-19 19:12:31

问题


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?


回答1:


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.




回答2:


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.




回答3:


Click to the code where you want to debug and than press F9.




回答4:


UpTheCreek,

Not really a 'nice' way to do it, however, you can insert some 'flip-flop' code in your view that CAN have a breakpoint placed in it and then step from there. This code doesn't neccessarily have to perfom a function (tho obviously, would be useful if it did).

anyway, you don't want the crumbs, so here's the (meal) deal:

<%
    int rspId = 0;
    string uniqPageId = Guid.NewGuid().ToString().Replace("-", "");  
%>

then, simply place the breakpoint at the side of any of those variable definitions.

Not clean and definately a 'jfar' markdown candidate :-)



来源:https://stackoverflow.com/questions/4603246/why-cant-i-set-a-breakpoint-in-a-asp-net-view

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