From the course: Learning ASP.NET Core MVC

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Handle requests with controllers

Handle requests with controllers

From the course: Learning ASP.NET Core MVC

Start my 1-month free trial

Handle requests with controllers

- [Instructor] Now that we've got the ASP.NET Core MVC middleware registered in the application pipeline, let's add some controllers. Controllers are the traffic cop of your MVC application. They are responsible for receiving the request and figuring out what to do with it. In an ASP.NET Core MVC application, controllers are nothing more than classes. So in order to create a new controller, all you've got to do is add a new class to your application. Though ASP.NET Core MVC will find controller classes regardless of where they live in your project, the standard convention, simply for the sake of keeping your project organized, is to put all of your controller classes in a folder named Controllers. Now with that folder in place, let's add our new controller class. To do this, right click on the Controllers folder that we just created, and select Add, New Item, MVC Controller Class. Then, just accept the default name of HomeController. Notice how Visual Studio automatically defines a…

Contents