Developing Controllers
An ASP.NET 5 MVC controller handles user requests to your site. Recall that the routing engine uses the URL convention to route a request to your controller and on to a method on that controller. For example, a request for ./customer/edit/5 will, by default, route to your CustomerController.Edit(id) method; the value 5 will be passed as the id parameter.
The controller method is then responsible for connecting the request to your model and returning the appropriate view result. The Edit(id) method, for example, will likely use a DbContext (created in the prior section) to find a specific customer from the database.
The controller would pass the Customer instance from the model to the Customer/Edit view page and return a ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access