ASP.NET MVC Controllers Overview

ASP.NET MVC Controllers Overview:

Controllers are inherited from System.Web.Mvc.Controller. Controllers in ASP.NET MVC framework are the starting point. Controllers are the first to receive the request when the web application sends a HTTP requests. It decides which model will react and presented, after which the view is rendered.
Each method in controllers are known as action method. You can invoke it from the method name itself.
Now, we will create a new Controller. For this, we will create a new ASP.NET MVC empty web application.

Creating a empty ASP.NET MVC web application :

Step 1 : Select File > New > Project :

ASP.NET MVC Controller overview - Making the web application 1

ASP.NET MVC Controller overview – Making the web application 1

Step 2 : Name the application as MyMvcApplication

 

ASP.NET MVC Controllers

ASP.NET MVC Controller overview – Making the web application 2

Step 3 : Select as Empty website.

ASP.NET MVC Controllers

ASP.NET MVC Controller overview – Selecting Empty website

Step 4 : Creating a Controller.

After creating the application, visual studio will create all the necessary folders and other stuff which are essential for our MVC application. To create a new Controller, click on Controllers > Add > Controller  and name the Controller as HomeController.

ASP.NET MVC Controllers

ASP.NET MVC Controller overview – Selecting controller

Step 5 : Editing our controller.

After creation, a basic code will be present by default in HomeController.cs.

Edit the HomeController.cs as below :

using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Web;
 using System.Web.Mvc;

namespace MyMvcApplication.Controllers
 {
 public class HomeController : Controller
 {
 //
 // GET: /Home/

public String Index()
 {
 return "Hello, I'm a simple ASP.NET MVC CONTROLLER.";
 }

}
 }

We will be showing a simple string message when this method is called. Now run the web application.

ASP.NET MVC Controllers

ASP.NET MVC Controller overview – Running the website

Next section on ASP.NET MVC Actions


  1. Base64Encode.io - Realtime Encode your string to Base64 format.
  2. Base64Decode.io - Realtime Decode Base64 data to plain text.
  3. Md5Hash.io - Realtime Encoding in Md5Hash.

2 thoughts on “ASP.NET MVC Controllers Overview”

  1. Pingback: ASP.NET MVC Actions Example • ParallelCodes;

  2. Pingback: ASP.NET MVC Tutorial • ParallelCodes;

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.