What you want to see on DotNetFunda.com ?
Go to DotNetFunda.com
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 28162 |  Welcome, Guest!   Register  Login
Home > Articles > ASP.NET > Beginner’s Guide: How IIS Process ASP.NET Request

Beginner’s Guide: How IIS Process ASP.NET Request

22 vote(s)
Rating: 4.55 out of 5
Article posted by Abhijit Jana on 3/14/2010 | Views: 156709 | Category: ASP.NET | Level: Beginner red flag


This article describes how the IIS process clients requests and responses.

Introduction
When request come from client to the server a lot of operation is performed before sending response to the client. This is all about how IIS Process the request.  Here I am not going to describe the Page Life Cycle and there events, this article is all about the operation of IIS Level.  Before we start with the actual details, let’s start from the beginning so that each and everyone understand it's details easily.  Please provide your valuable feedback and suggestion to improve this article.

What is Web Server ?

When we run our ASP.NET Web Application from visual studio IDE, VS Integrated ASP.NET Engine is responsible to execute all kind of asp.net requests and responses.  The process name is "WebDev.WebServer.Exe" which actually takw care of all request and response of an web application which is running from Visual Studio IDE.

Now, the name “Web Server” come into picture when we want to host the application on a centralized location and wanted to access from many locations. Web server is responsible for handle all the requests that are coming from clients, process them and provide the responses.


What is IIS ?
IIS (Internet Information Server) is one of the most powerful web servers from Microsoft that is used to host your ASP.NET Web application. IIS has it's own ASP.NET Process Engine  to handle the ASP.NET request. So, when a request comes from client to server, IIS takes that request and  process it and send response back to clients.

Request Processing :


Hope, till now it’s clear to you that what is Web server and IIS is and what is the use of them. Now let’s have a look how they do things internally. Before we move ahead, you have to know about two main concepts

1.    Worker Process
2.    Application Pool


Worker Process:  Worker Process (w3wp.exe) runs the ASP.Net application in IIS. This process is responsible to manage all the request and response that are coming from client system.  All the ASP.Net functionality runs under the scope of worker process.  When a request comes to the server from a client worker process is responsible to generate the request and response. In a single word we can say worker process is the heart of ASP.NET Web Application which runs on IIS.

Application Pool:  Application pool is the container of worker process.  Application pools is used to separate sets of IIS worker processes that share the same configuration.  Application pools enables a better security, reliability, and availability for any web application.  The worker process serves as the process boundary that separates each application pool so that when one worker process or application is having an issue or recycles, other applications or worker processes are not affected. This makes sure that a particular web application doesn't not impact other web application as they they are configured into different application pools.



Application Pool with multiple worker process is called “Web Garden”.

Now, I have covered all the basic stuff like Web server, Application Pool, Worker process. Now let’s have look how IIS process the request when a new request comes up from client.

If we look into the IIS 6.0 Architecture, we can divided them into Two Layer


1.    Kernel Mode
2.    User Mode

Now, Kernel mode is introduced with IIS 6.0, which contains the HTTP.SYS.  So whenever a request comes from Client to Server, it will hit HTTP.SYS First.



Now, HTTP.SYS is Responsible for pass the request to particular Application pool. Now here is one question, How HTTP.SYS comes to know where to send the request?  This is not a random pickup. Whenever we creates a new Application Pool, the ID of the Application Pool is being generated and it’s registered with the HTTP.SYS. So whenever HTTP.SYS Received the request from any web application, it checks for the Application Pool and based on the application pool it send the request.


So, this was the first steps of IIS Request Processing.

Till now, Client Requested for some information and request came to the Kernel level of IIS means at HTTP.SYS. HTTP.SYS has been identified the name of the application pool where to send. Now, let’s see how this request moves from HTTP.SYS to Application Pool.

In User Level of IIS, we have Web Admin Services (WAS) which takes the request from HTTP.SYS and pass it to the respective application pool.



When Application pool receive the request, it simply pass the request to worker process (w3wp.exe) . The worker process “w3wp.exe” looks up the URL of the request in order to load the correct ISAPI extension. ISAPI extensions are the IIS way to handle requests for different resources. Once ASP.NET is installed, it installs its own ISAPI extension (aspnet_isapi.dll) and adds the mapping into IIS.  

Note : Sometimes if we install IIS after installing asp.net, we need to register the extension with IIS using aspnet_regiis command.


When Worker process loads the aspnet_isapi.dll, it start an HTTPRuntime, which is the entry point of an application. HTTPRuntime is a class which calls the ProcessRequest method to start Processing.



When this methods called, a new instance of HTTPContext is been created.  Which is accessible using HTTPContext.Current  Properties. This object still remains alive during life time of object request.  Using HttpContext.Current we can access some other objects like Request, Response, Session etc.


After that HttpRuntime load an HttpApplication object with the help of  HttpApplicationFactory class.. Each and every request should pass through the corresponding HTTPModule to reach to HTTPHandler, this list of module are configured by the HTTPApplication.

Now, the concept comes called “HTTPPipeline”. It is called a pipeline because it contains a set of HttpModules ( For Both Web.config and Machine.config level) that intercept the request on its way to the HttpHandler. HTTPModules are classes that have access to the incoming request. We can also create our own HTTPModule if we need to handle anything during upcoming request and response.


HTTP Handlers are the endpoints in the HTTP pipeline. All request that are passing through the HTTPModule should reached to HTTPHandler.  Then  HTTP Handler  generates the output for the requested resource. So, when we requesting for any aspx web pages,   it returns the corresponding HTML output.

All the request now passes from  httpModule to  respective HTTPHandler then method and the ASP.NET Page life cycle starts.  This ends the IIS Request processing and start the ASP.NET Page Lifecycle.


Conclusion

When client request for some information from a web server, request first reaches to HTTP.SYS of IIS. HTTP.SYS then send the request to respective  Application Pool. Application Pool then forward the request to worker process to load the ISAPI Extension which will create an HTTPRuntime Object to Process the request via HTTPModule and HTTPHanlder. After that the ASP.NET Page LifeCycle events starts.

This was just overview of IIS Request Processing to let Beginner’s know how the request get processed in backend.  If you want to learn in details please check the link for Reference and further Study section.

Reference and Further Study
A low-level Look at the ASP.NET Architecture
IIS Architecture

If you like this article, subscribe to our RSS Feed. You can also subscribe via email to our Interview Questions, Codes and Forums section.

Page copy protected against web site content infringement by Copyscape
Found interesting? Add this to:



Please Sign In to vote for this post.

About Abhijit Jana

Experience:3 year(s)
Home page:http://abhijitjana.net
Member since:Wednesday, December 24, 2008
Level:Bronze
Status: [Member] [MVP]
Biography:He has done Master Degree in Computer Application and currently working as a Sr. S/W Developer in a US based MNC and having more than 3 years exp. He has worked with all the .NET framework and good exposer in Web and Windows based development using Microsoft Technology . Currently he working with C# 3.5, ASP.NET 3.5, Enterprise Library 4.1 and SDL Tridion also Exploring VS 2010 with .NET 4.0.
 Responses
Posted by: Abhi2434 | Posted on: 15 Mar 2010 04:15:50 AM

Boss, u r genius... Even I didnt know these low level IIS stuffs.. Came to know about them from this.

Cheers...
Great work dude.

Posted by: Brk007 | Posted on: 20 Mar 2010 11:20:13 AM

Thanks Abhijith what software you used for images? Is it visio?

Posted by: Cp_raj | Posted on: 25 Mar 2010 09:30:17 AM

Great Abhijith...Great article

Posted by: Cp_raj | Posted on: 25 Mar 2010 09:31:11 AM

Also Write the process for iis 7.0

Posted by: Vivek_viv | Posted on: 07 Apr 2010 01:09:52 AM

Dada Khub bhaalooo......
Created shades of ur footstep here also ... good one ...
Keep Writing

Posted by: Debanjan | Posted on: 25 Apr 2010 04:08:31 AM

Great article man..
Can you write an article like this on ASP.Net Page Life Cycle..it will really help ppl like me who are just starting off with ASP.Net.
Thanxx

Posted by: Ranu.mandan | Posted on: 27 Apr 2010 05:13:29 AM

I can find no other article on net with such a simple explanation and illustration..
thx for your effort

Posted by: Walia_jagwinder | Posted on: 29 Apr 2010 06:21:18 AM

Hey that was nice article thanks

but i have question

what happen when we create different pool for different applications?

Posted by: Anilmca11 | Posted on: 12 May 2010 05:17:30 AM

Really You helped me a lot Abhijith,

What a Great Post It is; Your presenation also excellent.

Regards,
Anil.

Posted by: Sarkarzinnia | Posted on: 05 Jun 2010 02:41:47 PM

This article is too simple n that's why i could understand it. Its simply great.
Rgds,
Zinnia

Posted by: Laxmikusum | Posted on: 19 Nov 2010 02:15:15 AM | Points: 25

very good article for beginners to understand basics. Thanks for your efforts.

Posted by: Schatak | Posted on: 04 Dec 2010 08:08:44 AM | Points: 25

nice article....nice explanation...thanks

Posted by: Anishacsc | Posted on: 12 Dec 2010 04:39:19 AM | Points: 25

Excellent. Thanks a lot

Posted by: Navalemanoj0405 | Posted on: 23 Dec 2010 01:04:21 AM | Points: 25

nice yaar

Posted by: Kitchu177 | Posted on: 23 Feb 2011 09:13:25 AM | Points: 25

Very good article... thanks for the good attempt.. cheers

Posted by: Rsthil | Posted on: 23 Apr 2011 01:57:20 AM | Points: 25

Thanks
Great article.Keep posting.


Posted by: Mahindra21 | Posted on: 08 Jun 2011 07:30:42 AM | Points: 25

This is realy, great article, to understand actual processing, internally.

Posted by: Prabhash | Posted on: 08 Jul 2011 09:11:14 AM | Points: 25

very good article for all

Posted by: Samir0005 | Posted on: 04 Oct 2011 12:42:12 PM | Points: 25

Realy it is the great one.I was ried to get this concept but after a long time i got the solution.realy it is very very good one.

Posted by: Muniraja.ah | Posted on: 23 Jan 2012 06:07:28 AM | Points: 25

thanks Bro.
Really i feel very happy by reading this article ,nice explanation lot of information.

Posted by: Xsmanjs | Posted on: 29 Feb 2012 11:29:37 PM | Points: 25

One of the best explanation. to the point and easy to undersatand.

Posted by: Gowthami | Posted on: 10 Oct 2012 06:15:19 AM | Points: 25

Thank you...this was very useful to me since i am beginner,i felt difficulty to understand but you article made it easy

Posted by: Sekar.C | Posted on: 29 Nov 2012 02:50:30 AM | Points: 25

Hi,Good job

Posted by: Mahalakshmisethu | Posted on: 13 Dec 2012 02:12:00 AM | Points: 25

You are a genius... Thanks a lot.

Posted by: Shantanupatel | Posted on: 11 Jan 2013 01:21:58 AM | Points: 25

The process name WebDev.WebServer40.exe come into picture when you run ASP.Net application with .Net Framework 4.0 and VS2010

Posted by: Sudeep9900 | Posted on: 16 Jan 2013 08:01:30 AM | Points: 25

it is a nice article.
But i have a doubt on WAS.
it is windows admin service or windows process activation service.

>> Write Response - Respond to this post and get points
Related Posts

This article describes how to specify an external AppSetting file from within web.config file and specify the settings value inside external file. It also describes related benefits and limitation of the external AppSetting file.

This article shows how to paginate (SEO friendly) a ListView using DataPager control without enabling ViewState.

Hi all i am sure many of us has faced problem of dropdown comming above the div here is a small solution for this May be you can try this it really works.....

In this article, i will show you, how to add holiday details within control and apply some style for those dates.The purpose of this article is add India holiday details within the calendar control and apply some style to those dates.

Data audit trail is one of the most required features in any project. This article will talk about audit trail through application using prototype pattern. Most the projects have three tier architecture and have the core business objects in place. In this article we will see how we can leverage the current business objects to implement auditing functionalities.

More ...
About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/21/2013 1:57:52 PM