O'Reilly logo

Microsoft Visual Studio 2015 Unleashed, Third Edition by Mike Snell, Lars Powers

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required