ASP.NET MVC Basics: Part 3


Introduction

In this article we will see how the ASP.Net MVC application executes. In the previous article1 and article2 we saw what MVC is. How is it different from ASP.Net? What is ASP.Net MVC? In this article we will see how the ASP.Net MVC application execution is going on.

From the last two articles you have some basic idea about what MVC is, and differences between MVC and ASP.Net. This article will demonstrate the steps involved in the ASP.Net MVC application execution process. In part 2 we saw that the request is first arriving at the controller, then the model will be prepared and finally the view is given as a response to the user but the actual flow is something different. So take a look at the following diagram to see the basic steps involved in ASP.Net MVC application execution.

mvc4.bmp

From the given diagram it is clear to you how the ASP.Net MVC application execution occurs. In the above diagram you see that first when the request comes from the user it's going to the global.asax file as all we know. When our application begins execution it first invokes the Application_Start event in the Global.asax file. In this Application_Start Event, only the routing table will perform the activity of mapping the user requested url with the application. After performing the routing, finally the request goes to the controller. We will explore more about the ASP.Net MVC routing in the next article. So I'm leaving it here to describe the ASP.Net MVC routing.

When the request arrives at the controller, it's defined by routing only; e.g. in our application there are many controllers so routing will map exact controller and the exact method of controller to be executed. Details about the controller you can find in my first article. This controller only will prepare the model and return the view to the user as a response.

Model is nothing but preparation of data e.g. populating data from database or some business logic or some data access. About model my first article will describe very well. Controller can return view without model or with model also. Controller is the thing in ASP.Net MVC which can perform so many actions like which model to prepare? What exactly user wants? And which view should be return to user? All is defined in controller only.

Finally the view i.e. user interface or designed screen for the user as a response is sent back to the user. About the view you can read more in my first article.

Conclusion:

In this way the ASP.Net MVC application execution occurs. In my next article we will see what ASP.Net MVC routing is. So keep reading.

Up Next
    Ebook Download
    View all
    Learn
    View all