在MVC ASPX视图设置断点 [英] Setting Breakpoints in MVC ASPX Views

查看:103
本文介绍了在MVC ASPX视图设置断点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我记得在斯科特谷剃刀公告对于剃须刀的观点完全调试器支持提及;我有pciated能够在剃刀观点,也碰到了不能够设置断点在视图中,只有迅速意识到这是一个ASPX视图,设置断点AP $ P $。 :P

I recall in Scott Gu's Razor announcement mention of full debugger support for Razor views; and I have appreciated being able to set breakpoints in Razor views, also bumped into not being able to set a breakpoint in a view, only to realize quickly that it is an ASPX view. :P

有时我不禁/改变一个现有的视图使用ASPX视图引擎,但:有没有办法我还没有学会在一个ASPX视图设置断点?如果没有,什么是未来最好的事情?有没有更好的解决办法比 Debugger.Break()和调试后恢复?

Sometimes I cannot help/change that an existing view uses the ASPX view engine, though: is there a way I've yet to learn to set breakpoints in an ASPX view? If not, what is the next best thing? Is there a better workaround than Debugger.Break() and reverting after debugging?

推荐答案

流行的看法相反,你其实也可以在ASPX意见中设置断点。

Contrary to popular belief you can actually set breakpoints in ASPX views.

在Visual Studio中,您可以在需要的位置定位光标,按<大骨节病> F9 (切换断点),它的完成。

In Visual Studio you can navigate your cursor at the desired location, hit F9 (Toggle Breakpoint) and it's done.

它可以剃刀和ASPX的意见来完成,甚至在ASPX页面(在的WebForms)。

It can be done in Razor and ASPX views, and even in ASPX pages (in WebForms).

如果您不能设置断点出现这意味着,给定的部分不是C#code,但在HTML一部分,而不是。你不能设置部分断点像&LT;跨度&GT; ,你只能把它傻℃之间;%%GT; 部分(在剃刀是 @ {...} @(...)或只是 @ ... )。

If you CAN'T set the breakpoint there that means that the given part is not C# code but the HTML part instead. You can't set breakpoints at parts like <span>, you can only set it between the silly <% and %> parts (in Razor it is @{...}, @(...) or simply @...).

另外,请确保您的应用程序构建,调试器连接到服务器实例(如果它是IIS前preSS切换到开发服务器上的项目属性,和VICA亦然)。

Also make sure your application is built, and the debugger is attached to the server instance (if it's on IIS express switch to Development Server in the project properties, and vica-versa).

停止开发服务器实例在任务栏上,重建项目,然后再次启动它。它应该命中断点就好了。

Stop the development server instances on the taskbar, rebuild your project and start it again. It should hit the breakpoint just fine.

这篇关于在MVC ASPX视图设置断点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆