Asp.Net MVC4 Controller class example

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.

New to Office 365 SharePoint Online? Get Office 365 Enterprise E3 Subscription & Try out all the features

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

Check out Best Alternative to InfoPath -> Try Now


(Installation & Features)

About Bijay Kumar

I am Bijay from Odisha, India. Currently working in my own venture TSInfo Technologies in Bangalore, India. I am Microsoft Office Servers and Services (SharePoint) MVP (5 times). I works in SharePoint 2016/2013/2010, SharePoint Online Office 365 etc. Check out My MVP Profile.. I also run popular SharePoint web site

View all posts by Bijay Kumar →