In this post we will discuss how to add a controller class in Asp.Net MVC 4 application. Also if you have created an Asp.Net MVC 4 demo using this article, then you will able to see 2 default controllers are there: HomeController.cs and AccountController.cs.
Controllers are responsible for responding to user input, often making changes to the model in response to user input.
Here we will see how we can add a Controller class. Remember every controller class is derived from System.Web.Mvc.Controller.
Follow below steps to add a controller class:
First Right click on the Controller folder then click on Add -> then click on Controller as shown in the figure below:
Then this will open the Add Controller dialog box. Thn give a controller name and select the template type, here we have selected Empty MVC Controller and then click on Add as shown in the figure below:
Now you can add a method like below in the controller class like below:
public string WelCome()
return “Welcome to MVC World !!!”;
Now if you want to run like below
Then the output will show like below:
Welcome to MVC World !!!
Download FREE SharePoint 2019 Installation PDF Guide
This FREE PDF contains, Steps by step guide to install SharePoint 2019 Preview, prerequisites, hardware and software new features. First impression to SharePoint Server 2019 new modern site, modern lists and modern document libraries.
You May Also like the Following SharePoint Online Tutorials: