---
title: "How to add a Controller in ASP.NET MVC"  
description: "How to add a Controller in ASP.NET MVC"  
author: "Anupam Mishra"  
published: 2016-01-30  
updated: 2016-01-30  
canonical: https://www.mindstick.com/forum/33941/how-to-add-a-controller-in-asp-dot-net-mvc  
category: "asp.net"  
tags: ["c#", ".net", "asp.net", "asp.net mvc"]  
reading_time: 2 minutes  

---

# How to add a Controller in ASP.NET MVC

Hi Everyone,\
[Now](https://yourviews.mindstick.com/view/81402/it-s-liberals-vs-progressives-in-us-politics-now), i am working on a very popular [topic](https://answers.mindstick.com/blog/313/how-to-generate-content-on-a-topic-using-ml-dot-net) of ASP.NET i.e. **[ASP.NET MVC](https://www.mindstick.com/forum/155798/what-is-caching-in-asp-dot-net-mvc)** framework. So, i want that can [anyone](https://www.mindstick.com/articles/23207/how-to-find-the-best-fit-job-for-anyone) [explain](https://www.mindstick.com/forum/157854/what-is-system-debugging-explain-some-system-debugging-tools-used-in-modern-computer-systems) how to adding a [controller](https://www.mindstick.com/blog/273/passing-values-from-controller-to-view-in-asp-dot-net-mvc) in a my [mvc application](https://www.mindstick.com/forum/12932/how-to-consume-webservices-from-asp-dot-net-mvc-application).\
\
Thank you.\

## Replies

### Reply by Anupam Mishra

[MVC](https://www.mindstick.com/forum/155803/define-cache-profile-in-mvc) stands for model-view-controller. MVC is a pattern for developing applications that are well architected, testable and easy to maintain. MVC-based applications contain:

- **M****odels:** Classes that represent the data of the application and that use validation logic to enforce business rules for that data.
- **V****iews:** Template files that your application uses to dynamically generate HTML responses.
- **C****ontrollers:** Classes that handle incoming browser requests, retrieve model data, and then specify view templates that return a response to the browser.

\
Let's begin by creating a controller class. In Solution Explorer, right-click the Controllers folder and then click Add, then Controller.

![How to add a Controller in ASP.NET MVC](https://www.mindstick.com/mindstickforums/2cd92a15-53d8-48e5-ab87-35860d2fd3c0/images/dafb7ed8-b513-4f71-88d9-4d954757b5cc.png)\
\
In the Add Scaffold dialog box, click MVC 4 Controller - Empty, and then click Add.\
and name your controller "HomeController" and click Add.Now we will write the following code:\

```
using System.Web;
using System.Web.Mvc; 
 
namespace MyApp.Controllers 
{ 
    public class HomeController : Controller 
    { 
        //
        // GET: /Home/
 
        public string Index() 
        { 
            return "Hi guest this is index section; 
        } 
 
        //
        // GET: /Home/Welcome/
 
        public string Welcome() 
        { 
            return "This is the Welcome action method..."; 
        } 
    } 
}
```

We run this project then it produced following results:

![How to add a Controller in ASP.NET MVC](https://www.mindstick.com/mindstickforums/2cd92a15-53d8-48e5-ab87-35860d2fd3c0/images/f74f662f-2bd2-47b5-9ba3-8a94f95f3a5b.png)![How to add a Controller in ASP.NET MVC](https://www.mindstick.com/mindstickforums/2cd92a15-53d8-48e5-ab87-35860d2fd3c0/images/e783bfaa-d1b8-4563-802a-fa0854cd3dc3.png)\


---

Original Source: https://www.mindstick.com/forum/33941/how-to-add-a-controller-in-asp-dot-net-mvc

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
