Hello World First MVC Application

This article shows how to start writing MVC applications.
 
 Step 1: From the Visual Studio menus select "File" -> "New" -> "Project...".

MVC-1.jpg
 
 Step 2: Select the Template web the "ASP.NET MVC 4 Web Application".

MVC-2.jpg
 
 Then select the "Empty" template and Razor or ASPX View engine. I chose ASPX here to use ASPX pages for the view.

MVC-3.jpg
 
 Now a MVC web application has been added to n the solution.
 
 Step 3: In this step we will add the Controller to our application.
 
Then just right-click on Controller in the Solution window then "Add" -> "Controller".

MVC-4.jpg
 
 Step 4: Set the name for the controller and add it.

MVC-5.jpg
 
 Step 5: In the next step we will add the view for our controller. To do that open the HelloWorld controller.
 
Right-click on the Index action and click on "Add View".

MVC-6.jpg

MVC-7.jpg
 
 Do not check the "Use a layout or master page" because we do not have any master page in out application. After adding the view open the source and add your design. I will add one simple line in it, "Hello world! This is my first MVC application".

MVC-8.jpg

MVC-9.jpg

MVC-10.jpg
 
 Final Step: Open the RouteConfig file and set the default Action to open.

MVC-11.jpg

MVC-12.jpg
 
 Now press F5 and run the application.
 
 Here is the output.

MVC-13.jpg


Similar Articles