1. Go to File, New, then Project.
2. Under Web Template select ASP.Net MVC 4 Web Application and give it a meaningful name.
And then click OK. After that another dialog box opens.
3. Select Empty Template and
View engine as
Razor.
Selecting MVC Project as Empty creates basic folder structure for the project. You will also see two View Engine ASPX and Razor. Razor view engine is new and improved view engine introduced in ASP.NET MVC 3. In Solution Explorer, you will see the following three main architecture components of ASP.NET MVC project that is Model, View and Controller.
If you try to run your Application, you will get HTTP 404 Error because we have created ASP.NET Empty Web Application and our application contains nothing/no U.I. to display.
Let’s Add a Controller in our MVC project. All of the request (by user) is handled by Controller. Right Click on Controller Folder and then Go to Add, then Click on Controller.
In Add Controller Dialog, Add Controller name as Home. By Convention, Every controller name ends with Controller Word so, our Controller name becomes HomeController. Never try to Remove Controller word from your Controller Name. In Scaffolding options, select Empty MVC controller template. This is our first application and we try to keep it as simple as possible.
After Adding the Home Controller you will see HomeController with an Index method.
Make a small change in Index Action method. Change the return type of Index method to string and return a string i.e. "Hello World Application using ASP.NET MVC 4". We will learn about View and ActionResult in our next post.