Library Management using ASP.Net MVC (Part 2) Request Lifecycle

It is important to understand the request lifecycle in ASP.Net MVC before we proceed with other tutorials. In this article I will briefly discuss to you how the ASP.Net MVC handles the request.

When we make http request in our MVC application it will look for the registered routes in URL Routing Module to determine which controller should handle the request.

You can check the registered routes in App_Start folder then open the RouteConfig.cs

route config

Look at the value of url in routes.MapRoute and compare it to the url that we have in our browser.

edit url

In the above image the controller is the Books, then the action is Edit and the id is 1.

When we access the above url, it will first look at the registered routes to determine which controller will handle the request. After determining the controller it will initialize the controller and a module called Action Invoker will find what action should will be executed for the request.

If you look at the code in BooksController, you will find the Edit method.

edit code

After executing the action, if the result is a view, the view engine will find the necessary view in Views Folder. In this case it will look for Views -> Books -> Edit.cshtml then it will render the view for the user.

books view

Related Articles

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s