In this tutorial we will see how to create a first MVC application using VS 2010 and the MVC 2 template. This complete series is divided in to 50 parts with labs and video demos.
How to create a simple hello world ASP.NET MVC? (Tutorial No: 1)
Contents
Introduction
Goal: - Create a simple ASPX page with Hello world controller.
Video demonstration
Step1:- Create project
Step 2:- Add controller
Step 3:- Add View
Step 4:- Run the application
So what’s in the next tutorial?
In this tutorial we will see how to create a first MVC application using VS 2010 and the MVC 2 template. This complete series is divided in to 50 parts with labs and video demos. We hope this complete series will help you to understand MVC step by step in a structured manner.
Click here for the Part 2 of ASP.NET MVC article.
Click here for the Part 3 of ASP.NET MVC article.
Click here for the Part 4 of the ASP.NET MVC article.
Click here for the Part 5 of the ASP.NET MVC article.
Click here for the Part 6 of the
ASP.NET MVC article.
Click here for the Part 7 of the
ASP.NET MVC article.
Click here for the Part 8 of the
ASP.NET MVC article.
Click here for the Part 9 of the
ASP.NET MVC article.
Get more videos on .NET/ASP.NET interview questions and answers
Pre-requisite for MVC
• Visual Studio 2010 or the free Visual Web Developer 2010 Express. These include ASP.NET MVC 2 template by default.
• Visual Studio 2008 SP1 (any edition) or the free Visual Web Developer 2008 Express with SP1. These do not include ASP.NET MVC 2 by default; you must also download and install ASP.NET MVC 2 from http://www.asp.net/mvc/ .
In this lab we will create a simple hello world program using MVC template. So we will create a simple controller, attach the controller to simple index.aspx page and view the display on the browser.
In case you are fed up to read the complete article watch the below 5 minutes video to understand the same.
Create a new project by selecting the MVC 2 empty web application template as shown in the below figure.

Once you click ok, you have a readymade structure with appropriate folders where you can add controllers, models and views.

So let’s go and add a new controller as shown in the below figure.

Once you add the new controller you should see some kind of code snippet as shown in the below snippet.
public class Default1Controller : Controller
{
//
// GET: /Default1/
public ActionResult Index()
{
return View();
}
}
Now that we have the controller we need to go and add the view. So click on the Index function which is present in the control and click on add view menu as shown in the below figure.

The add view pops up a modal box to enter view name which will be invoked when this controller is called as shown in the figure below. For now keep the view name same as the controller name and also uncheck the master page check box.
Once you click on the ok button of the view, you should see a simple ASPX page with the below HTML code snippet. In the below HTML code snippet I have added “This is my first MVC application”.
If you do a CNTRL + F5 you should see an error as shown in the below figure. This error is obvious because we have not invoked the appropriate controller / action.

If you append the proper controller on the URL you should be able to see the proper view.

So have a toast of beer for your first ASP.NET MVC application.

So what’s in the next tutorial?
Now that we have created a simple MVC hello world, it’s time to see how we can pass data from controllers to views. The first hit comes to the controller which will load your business objects or model and you would like to transfer these objects to the view to display them. Click here to view the 2nd part of ASP.NET MVC in article.