I'm used to C# and vb.net winforms, and usually can find all the errors I need just by setting a breakpoint and stepping through my code.
I would like to know what I'm doing wrong.
I'm placing a breakpoint here:
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();
}
Yet again I have no clue where or why it errored out exactly. How can I find out why or better yet what error it is throwing?
I'm using VS2012 mvc4 c#.
Simply execute the DebugView program file (dbgview.exe) and DebugView will immediately start capturing debug output. Note that if you run DebugView on Windows 2000/XP you must have administrative privilege to view kernel-mode debug output.
Click your ViewBag. MyData and hit F9 . When debugging, once the break-point is hit, hover your mouse over the ViewBag to see its contents.
You need to put breakpoints in your view itself. You can place breakpoints on anything using razor syntax such as:
@Html.ActionLink
@{ var x = model.x; }
If you are getting a null reference exception, put breakpoints on places where you consume the model in your view.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With