Saturday, November 3, 2018

Asp.net MVC Controllers

Asp.net MVC Controllers are the center point of all the data flow in the application. It takes the input HTTP request and rendering the exact output. So controllers are controlling the all the flow. Whenever a new request comes from the browser then the controller takes the request and process the which Model will be taken, and then it takes the data from the model to the respective view.

Points To Remember
  • Controllers are the Classes derived from System.Web.Mvc.Controller.
  • Controllers contain public methods. These all methods are called Action Methods.
  • The class name must end with Controller like  TestController
  • All Controller Classes available in Controller Folder Structure.
Steps To Create Controller 

Step 1 
               Open the Visual Studio and click on File Tab --> New --> Project Menu

             
Asp.net MVC Controllers
 Step 2
               Select Web from left pan next select asp.net web application and give the proper Name,     Location, and Solution at below pan finally click OK button. then you get one more Popup box here you choose the MVC option. Click OK button. asp.net creates a template for a project.
                     
Asp.net MVC Controllers Tutorials

Step 3

           You can find the Controller folder has some Controller Classes with .cs extensions at the right side. every controller ends with Controller. You can observe from Controller folder has three classes. These classes are AccountController.cs, HomeController, and ManageCotroller 

Asp.net MVC Controllers Tutorials

If you open any one controller then you find the controller inherited from Controller. and each controller has Action Methods. From below image, you can observe. 

Asp.net MVC Controllers Tutorials


















No comments: