Build Asp .Net MVC Application From Scratch
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.
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.
It will create a basic empty project with necessary folders. Right click on the Controller folder and select option to add a new Controller.
Choose an option to create an Empty MVC controller with name Home.
This will create a HomeController with Index ActionMethod in it.
Next step is to create a View for your Index method. Right click on your Index ActionMethod name and select the option Add View.
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.
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.
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.
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.