How does IIS server identify that request is mvc request?

Mrudang Vora picture Mrudang Vora · Aug 5, 2014 · Viewed 9.3k times · Source

In asp.net life cycle, on basis of the extension (.aspx), the request would be identified and handled by aspnet_isapi.dll and then httpapplication object is created followed by request and response objects and then request is processed by ProcessRequest() method.

I was going through mvc page life cycle

I have doubt about how the IIS server is able to identify the incoming request is MVC request?

Answer

Mrudang Vora picture Mrudang Vora · Apr 2, 2015

Both the answers with some research I did, collectively resolves my question.

Step 1: From the below mentioned article #1 (which I found during my research):

From a very high view, IIS is just a process which is listening on a particular port (usually 80). Listening means it is ready to accept a connections from clients on port 80. A very important thing to remember is: IIS is not ASP.NET. This means that IIS doesn't know anything about ASP.NET; it can work by itself.

Step 2:

Note: When we deploy and start the application in IIS, it would call Application_Start which would register the routes. So, when MVC request comes to IIS, we are ready with our Route Table to handle this request.

Step 3:

As mentioned by @Babin, IIS doesn't know how to handle the request but because of ASP.NET framework, the request automatically goes to managed handlers.

Step 4:

As mentioned by @Rune, the request is intercepted by the UrlRoutingModule which in turn gets object of MvcRouteHandler class that will ultimately map to controller and action to handle the request.

Step 5:

As mentioned in one of SO question's comments:

If no routes match, the UrlRoutingModule object does nothing 
and lets the request fall back to the regular ASP.NET or IIS request processing.

References:

I found good articles to read through and clear out the doubts in IIS request processing.

1) The following link has in-depth explanation for how IIS handles ASP.NET WebForms request: http://www.codeproject.com/Articles/121096/Web-Server-and-ASP-NET-Application-Life-Cycle-in-D

2) The following links explains how IIS handles MVC requests using managed handlers: http://blogs.msdn.com/b/tmarq/archive/2010/04/01/asp-net-4-0-enables-routing-of-extensionless-urls-without-impacting-static-requests.aspx

3) MVC Lifecycle: http://pratiktips.blogspot.de/2012/08/the-magic-of-aspnet-mvc-model-binding.html