---
title: "What is Asp.Net MVC Controller?"  
description: "What is Asp.Net MVC Controller?"  
author: "Anonymous User"  
published: 2020-01-30  
updated: 2020-01-30  
canonical: https://www.mindstick.com/forum/155763/what-is-asp-dot-net-mvc-controller  
category: "asp.net mvc"  
tags: ["asp.net mvc"]  
reading_time: 2 minutes  

---

# What is Asp.Net MVC Controller?

[Please tell me](https://www.mindstick.com/forum/33900/please-tell-me-what-are-the-technique-to-content-optimization) about [asp.net](https://www.mindstick.com/articles/934/default-folders-available-inside-the-asp-dot-net-application-folder) [MVC controller](https://www.mindstick.com/forum/12890/how-can-asp-dot-net-mvc-controller-return-an-image) and how we create it with an example and an image.

## Replies

### Reply by Nishi Tiwari

## [ASP.NET MVC](https://www.mindstick.com/forum/155798/what-is-caching-in-asp-dot-net-mvc) Controller

The controller is defined as a class that handles user requests. It retrieves data from the Model and renders view as a response.

In ASP.NET MVC framework the requested URLs are mapped to the classes which are referred to as controllers. The controller processes the incoming requests handles user inputs and interactions and executes appropriate business logic.

**[The ControllerBase class is a base class for all the controller classes.](https://www.mindstick.com/forum/155762/explain-different-templates-in-mvc)** It provides general MVC handling. A controller usually performs the following tasks.

o It locates for the appropriate action method to call and validate it.

o It gets the values so as to use the action method's arguments.

o It handles all errors which might occur during the execution of the action.

o It uses the WebFormViewEngine class for rendering the ASP.NET page.

All controller classes must be named with the "Controller" suffix.

## Create a Controller

You can create a controller for an application by adding a new item to the controller folder. First right click on the controller folder and click add -> controller as shown below.

![What is Asp.Net MVC Controller?](https://www.mindstick.com/mindstickforums/1c24a63b-6545-4525-986a-72c7b3bdc611/images/be842111-a5d7-4b19-83bc-a8aea4361ee8.png)

Provide controller name and then click Add.

![What is Asp.Net MVC Controller?](https://www.mindstick.com/mindstickforums/1c24a63b-6545-4525-986a-72c7b3bdc611/images/c08609b8-8ae8-4f07-ab35-b09e80ceefbe.png)

After adding the controller project will create a folder with the same name as the controller name in the view folder so as to store the view files belongs to the controller.

The controller will contain the default code like below.

## // MusicStoreController.cs

```
1.	using System;
2.	using System.Collections.Generic;
3.	using System.Linq;
4.	using System.Web;
5.	using System.Web.Mvc;
6.	namespace MvcApplicationDemo.Controllers
7.	{
8.	    public class MusicStoreController : Controller
9.	    {
10.	        // GET: MusicStrore
11.	        public ActionResult Index()
12.	        {
13.	            return View();
14.	        }
15.	    }
16.	}
```

To access the controller we add an index file to the MusicStore folder inside the view folder. The index file will contain the following code as given below.

## // index.cshtml

```
1.	<div class="jumbotron">
2.	    <h2>Welcome to the music store.</h2>
3.	</div>
```

Output:-

![What is Asp.Net MVC Controller?](https://www.mindstick.com/mindstickforums/1c24a63b-6545-4525-986a-72c7b3bdc611/images/8b1eb94b-62ce-419d-80b8-1ed116856602.png)


---

Original Source: https://www.mindstick.com/forum/155763/what-is-asp-dot-net-mvc-controller

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
