What you want to see on DotNetFunda.com ?
Go to DotNetFunda.com
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 9816 |  Welcome, Guest!   Register  Login
Home > Articles > ASP.NET > How to create a simple hello world ASP.NET MVC? (Tutorial No: 1)

How to create a simple hello world ASP.NET MVC? (Tutorial No: 1)

Article posted by Questpond on 4/11/2011 | Views: 121374 | Category: ASP.NET | Level: Advance | Points: 250 red flag


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?   
                          

Introduction

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/  .


Goal: - Create a simple ASPX page with Hello world controller.

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.

Video demonstration

In case you are fed up to read the complete article watch the below 5 minutes video to understand the same.

Step1:- Create project

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.

Step 2:- Add controller

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();
}
}

Step 3:- Add 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”.


Step 4:- Run the 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.

 

If you like this article, subscribe to our RSS Feed. You can also subscribe via email to our Interview Questions, Codes and Forums section.

Page copy protected against web site content infringement by Copyscape
Found interesting? Add this to:



Please Sign In to vote for this post.

Experience:0 year(s)
Home page:http://www.questpond.com
Member since:Wednesday, September 03, 2008
Level:Starter
Status: [PanelMember] [Member] [Microsoft_MVP] [MVP] [Administrator]
Biography:

I am a Microsoft MVP for ASP/ASP.NET and currently a CEO of a small
E-learning company in India. We are very much active in making training videos ,
writing books and corporate trainings. Do visit my site for 
.NET, C# , design pattern , WCF , Silverlight
, LINQ , ASP.NET , ADO.NET , Sharepoint , UML , SQL Server  training 
and Interview questions and answers

 Responses
Posted by: Laghaterohan | Posted on: 12 Apr 2011 04:59:50 AM | Points: 25

Indeed nice one..when shall i expect part 2 and so on??

Posted by: Susanthampy | Posted on: 13 Jun 2011 08:50:45 AM | Points: 25

nice

Posted by: Palpatel090 | Posted on: 16 Sep 2011 02:33:29 AM | Points: 25

Good Post....
Its really help full....
keep contributing

Pal (Parthiv) Patel

Download Window 8 Free
-http://palpatel090.blogspot.com

Asp.net Tips :
-http://aspdotnetmania.blogspot.com

Posted by: Sanepete | Posted on: 19 Sep 2011 06:59:25 AM | Points: 25

The pictures have disappeared!

Shocking!

Posted by: Irshadvaza | Posted on: 30 Dec 2011 04:43:36 AM | Points: 25

Very good post.It is very useful to understand mvc.Expect with Jquery in part 2.



Posted by: Akiii | Posted on: 16 Jan 2012 12:06:55 AM | Points: 25

great starting Sir !

Thanks and Regards
Akiii

>> Write Response - Respond to this post and get points
Related Posts

This article describes how to change background colour of the whole item of a list view based on the search string

In this article ,we will see how to create a Chart in SSRS(RDLC) Report.

This post is just a guide/approach for the bill desk payment gateway integration.

ASP.Net Dynamic Data is used to develop data driven web applications using dynamic page and field templates. In this article we will see how to customize our ASP.Net Dynamic Data web application.

In this article, i have tried to show , 'how to send bulk email using Gmail'.

More ...
About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/25/2013 7:59:53 PM