Pak*_*akk 6 c# debugging asp.net-mvc razor
我已经习惯了C#和vb.net winforms,通常可以通过设置断点和单步执行代码来找到我需要的所有错误.
我想知道我做错了什么.
我在这里放置一个断点:
public ActionResult Index(int id)
{
var cnty = from r in db.Clients
where r.ClientID == id
select r;
if (cnty != null) // breakpoint here
{
return View(cnty); // F11 jumps over this section of code returning me to the error page below.
}
return HttpNotFound();
}
Run Code Online (Sandbox Code Playgroud)
然而,我再也不知道它究竟在哪里或为什么会出错.我怎样才能找出原因或更好的错误呢?
我正在使用VS2012 mvc4 c#.
Dav*_*d L 11
您需要在视图中放置断点.您可以使用razor语法在任何地方放置断点,例如:
@Html.ActionLink
@{ var x = model.x; }
Run Code Online (Sandbox Code Playgroud)
如果您获得空引用异常,请在视图中使用模型的位置放置断点.
| 归档时间: |
|
| 查看次数: |
27199 次 |
| 最近记录: |