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 ...
Get Microsoft Visual Studio 2015 Unleashed, Third Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.