It would help to see the exception you are seeing. I'm guessing that you are seeing an exception when the page renders. As "David L" identified above, you want to set your breakpoint in the Razor view (Index.cshtml
).
But why?
It helps to understand the lifecycle of a request/response in MVC. Here is the first example I found with a visual. There are sure to be others.
- Request is routed to your Controller
- The Controller returns a
ActionResult
: return View(cnty);
- MVC passes the
ActionResult
to your View
- The exception occurs in your
Index.cshtml
when attempting to use the ActionResult
.
I'm going to speculate that it has something to do with a disposed DB context object. Depending on the ORM you are using, the result of
from r in db.Clients
where r.ClientID == id
select r
is an IQueryable<Client>
. You may be surprised to find out that your code has not yet contacted the database before return View(cnty);
is executed. Try this instead:
return View(cnty.ToList());
Again, the exact error you are seeing is important. My suggestion presumes Index.cshtml
begins with:
@model IEnumerable<Client>
Update:
Per OP's comment below, the stack trace is not available. There are many questions dedicated to seeing the stack trace in your browser during development. At least confirm that the following is set in your web.config
<system.web>
<customErrors mode ="Off" />
</system.web>