The Controller gets the request from the End user.
The Controller decides the action for the request made by the user.
The action will be performed by the controller.
The relevant view is shown by the controller.
Adding Controller in ASP.Net MVC
Step 1
Follow the below steps to add the controller.
Note
Make sure that Visual Studio 2013 ultimate is installed. Because Visual Studio Ultimate has all the updated features.
Open the Visual Studio 2013 ultimate.
Go to File->New->Project as shown in the below figure.
Then, the New Project window will appear as shown in the below figure.
Step 2
Select the Visual C#. Click on the WEB. Then, ASP.Net Web Application appears as shown in the following figure.
Step 3
Give the Name and click on the OK button as shown in the below figure.
Then the following window will appear.
Step 4
Click on MVC. Then, automatically the checkbox will be checked. Now, see the Change Authentication button as shown in the below figure.
Step 5
Click on Change Authentication button. Then the following window will appear.
Step 6
If wanted to set authentication, then change the authentication according to your requirement. All these authentication modes will be discussed later. Click on OK.
Again click on OK. Then, the MVC application will be created as shown in the below figure.
Step 7
See the Solution Explorer. Solution Explorer contains a folder called Controllers. Right click on Controllers folder and then Add->Controller as shown in the following figure.
Step 8
Click on Controller. Then, the following window will appear.
Step 9
Select the controller and MVC 5 Controller -Empty. Click on Add button as shown in the below figure.
There are some other options too which will be discussed in later chapters. The following window will appear, after clicking on the Add button.
Step 10
Remove the Default part in the controller name. Give the Name as you want and click on OK.
Note
Don't remove Controller in the Controller Name.
Then the controller code will be generated as shown in the below figure.