Build Asp .Net MVC Application From Scratch

Oct 29, 2014
Facebook Twitter Google Digg Reddit LinkedIn Pinterest StumbleUpon Email


In this blog post we will see how to create a basic Asp .Net MVC application. The purpose of this post is to server as a base for many other blog posts I have written or going to write in future.

Let's open Visual Studio and Navigate to the new Project Dialog. Select the options as highlighted in below screen shot.

MVC4 App

Next screen will provide you with bunch of options with types of applications you can create. Since we are planning to build a plain application which we can extend later, just select the Empty option.

MVC4 App

It will create a basic empty project with necessary folders. Right click on the Controller folder and select option to add a new Controller.

MVC4 App

Choose an option to create an Empty MVC controller with name Home.

MVC4 App

This will create a HomeController with Index ActionMethod in it.

MVC4 App

Next step is to create a View for your Index method. Right click on your Index ActionMethod name and select the option Add View.

MVC4 App

By default the dialog will have Index as the name of the View and we want to keep it that way. For now it is not going to be strongly typed and since we do not have any Layout page More on Layout Page Here we will leave that field Empty.

MVC4 App

It will create a new .cshtml file which will be our view. If you notice carefully the Index.cshtml file is added under "Home" folder in your "Views" folder. Let's add a simple

element that displays welcome message.

MVC4 App

And that's it. We now have our very first basic MVC application. Go ahead and lcick on the Run button and you will see your MVC application running.

MVC4 App

That's it for now guys. I will use this blog post as a reference post for many of the other MVC posts I do.