In this article we will learn how to create a MVC project.
ASP.Net MVC is basically an architectural pattern that allows us to create a dynamic website using HTML. This gives the feature of "TDD development".
The following is the procedure to create your first ASP.Net MVC project.
- Open Visual Studio and click on "File" -> "New" -> "Project...".
- You will see a screen. From here select Web and ASP.NET MVC4 Web Application and provide the name for this project and click OK.
When you click OK we will see an ASP.Net MVC New Project screen. From here select “Empty template “ and select Razor as ViewEngine. Here Razor is two types, one is ASPX and the other type is ViewEngine.
Here we will prefer “VIEWeNGINE” because it is much cleaner and better to use.
Here we will prefer “VIEWeNGINE” because it is much cleaner and better to use.
After clicking on OK, it will create a MVC project. In Solution Explorer we will see “Modal”, “view” , “controller” folder.
Now go to the Controller folder and add a new Controller to the project .
Right-click on the Controllers folder then select Add -> Controller.
Provide the name for this controller the As FirstController and click on Add and it will generate a file with the name FirstController.
Here when you will click on add this will add a class “FirstController.cs” class. It will be available in the Controller folder. This class will be inherited by the “Controller” base class.
Here this class will contain a method and the return type of this method is “ActionResult”.
Add ActionMethod To the Controller class
ActionMethods are used for handling “user request”, validation of user input, execute code and the o/p.
The MVC routing engine sendsthe user request to the appropriate ActionMethod.
Now open the “FirstController.cs” class and add anActionMethod and the provide name as “Index”.
The following code is for the FirstController class.
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- namespace FirstMvcApplication.Controllers
- {
- public class FirstController: Controller
- {
- //
- // GET: /Home/
- public string Index()
- {
- return "Hello, from first MVC application";
- }
- }
- }









Aarthna MaheshwariPosted May 29, 2015, 9:10 AM
Great!
NitinPosted May 23, 2015, 8:51 AM
nice
Santhakumar MunuswamyPosted May 22, 2015, 2:51 PM
Nice
Munesh SharmaPosted May 22, 2015, 11:53 AM
Thank you Prafulla .. I will correct this . :)
Prafulla ChoudharyPosted May 22, 2015, 8:48 AM
Razor and ASPX are types of ViewEngine.
Prafulla ChoudharyPosted May 22, 2015, 8:46 AM
Please Correct this line " Here Razor is two types, one is ASPX and the other type is ViewEngine.".
Vivek TripathiPosted May 22, 2015, 7:40 AM
Nice
Sandeep Singh ShekhawatPosted May 22, 2015, 12:55 AM
Good.