C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Articles » .NET Framework »

The thing that happens behind the scenes!!!


Posted Date: 26 Jan 2006    Resource Type: Articles    Category: .NET Framework
Author: HimaBindu VeeramachaneniMember Level: Diamond    
Rating: 1 out of 5Points: 50



Introduction


Many of us know that IIS is a web server and we use it in our .Net application since we need a web server to run a web application. But I wonder as many of us don't know the internal architecture of IIS. This article is written for beginners to know the architecture of IIS.

How the Simple Web page execution Happens?

As All of us know A Request comes from Client (Browser) and sends to Server (We call it as Web server) in turn Server Process the Request and sends response Back to the Client in according to the client Request

But internally in the Web server there is quite interesting process that happens. To get aware of that process we should first of all know about the architecture of the IIS

It mainly consists of 3 Parts/Files

1. Inetinfo.exec

2. ISAPI Filter (Container for Internet Server Application Interface dlls) ,

3. Worker Process (aspnet_wp.exe)

When ever a Request comes from the Client:


Inetinfo.exe is the ASP.Net Request Handler that handles the requests from the client .If it’s for static resources like HTML files or image files inetinfo.exe process the request and sent to client If the request is with extension aspx/asp inetinfo.exe processes the request to API filter. ISAPI filter will have several runtime modules called as ISAPI extensions. To process the request ISAPI filter takes the help of these runtime modules .The runtime module loaded for asp page is asp.dll. And for asp.net page it’s ASPNET_ISAPI.dll. From here the request is processed o the Worker Process. Worker Process will have several Application Domains

Application Domain


The purpose of the Application Domain is in order to isolate one application from another. When ever we create a new application, application Domains are created automatically by the CLRHost. Worker process will create a block of memory related to particular application. Application domains provide a more secure and versatile unit of processing that the common language runtime can use to provide isolation between applications. Application domains are normally created by runtime hosts. Runtime host is responsible for bootstrapping the common language runtime before an application is run.

Worker process sends the request to HTTPPIPE line.(HTTP Pipeline is nonetheless collection of .net framework classes). HTTP Pipeline compiles the request into a library and -makes a call to HTTP runtime and Runtime creates an instance of page class

public class File : System.Web.UI.Page
{
}

ASP.Net web page is a class derived from Page class ,this page class resides in system.web.dll

After creating instance pf Page class HTTP Runtime immediately invokes Process Request Method of Page class

Page Req = new Page();

Req.ProcessRequest();


Process Request Method Does Following things

1.Intialize the Memory

2.Load the View State

3.Page Execution and Post back Events

4.Rendering HTML Content

5.Releasing the memory

Process Request Method executes set of events for page class .These are calles as Page life cycle events.

Page Life Cycle Events


Page_Init
The server controls are loaded and initialized from the Web form’s view state. This is the first step in a Web form’s life cycle.

Page_Load
The server controls are loaded in the Page object. View state information is available at this point, so this is where you put code to change control settings or display text on the page.

Page_PreRender
The application is about to render the Page object.

Page_Unload
The page is unloaded from memory.

Page_Disposed
The Page object is released from memory. This is the last event in the life of a Page object.

Page_Error
An unhandled exception occurs.

Page_AbortTransaction
A transaction is aborted.

Page_CommitTransaction
A transaction is accepted.

Page_DataBinding
A server control on the page binds to a data source.

Process Request Method finally renders HTML Page

Dependencies:


When the request comes to ASP.net worker Process, it will be forwarded to HTTP Application factory. This Application Factory will maintain address of the Application Domains which are currently executing under worker process. If the required virtual directory application domain is unavailable it will create a new Application Domain. If the application domain is already existent, the request will be forwarded to Corresponding AppDomain.

Application Domain maintains Page handler factory class. This will contain all libraries addresses corresponding to webpage. If the requested webpage library is available the instance of the page class is created, if the library is unavailable the request will be forwarded to http pipeline.

Note:

In ASP 2.0 we don't need to install IIS in Your system. It comes with Built in ASP server

Is this Clear and enough Or Confusing!!!



Responses

Author: LAVANYA    31 Jan 2006Member Level: Bronze   Points : 0
Thanks for collecting lot of information on IIs and ASP.NET process.
Article is put ina Very clear and easily followed form.


Author: Brainstorming Guy    14 Feb 2006Member Level: Diamond   Points : 0
Adding more with Hima's article, i like to chip in and put some of my points.
When we request for a ASPX page, there is IISAPIRuntime interface..We have a processRequest method. This is the first method that gets executed when we request for a ASPX page.
1. Processrequest will be called by the aspnet_isapi.dll
2. Processrequest has 2 parameters InPtr ecb (Extension Control Bus ) and int iWrType which is the stream used for the execution of the page..


Regards,
Brainstorming Guy aka Venkatarajan A


Author: meenakshivs    10 Apr 2007Member Level: Bronze   Points : 0
Its not ISAPI Filer, Its ISAPI Filter


Author: Mohan Dass    27 Apr 2007Member Level: Bronze   Points : 0
It's very useful to know the basic things of the IIS Server. I like this article very much.. It's So simple to understand.. I appreciate the writer of this article to write more article like this........


Author: PRADEEP QUESS SANDEEP    21 Jan 2008Member Level: Bronze   Points : 0
Thanks, it's an awesome description that covers the whole IIS Architecture in one go. But still some questions for me remain unanswered -
1. How is the static HTML page handled by the inetinfo.exe?
2. How is the mapping process for the asp & aspx pages carried out?
3. How exactly does the worker process handle these requests?
I would appreciate if you could either explain me this in a bit more detail or provide me relevant links, books or other resources through which I could get the exact picture.




Author: HimaBindu Veeramachaneni    19 Jan 2009Member Level: Diamond   Points : 1
It's strange for me to see this article has been rejected . May I know the reason?


Author: Sidewinder2    20 Jan 2009Member Level: Gold   Points : 0
Hello Mate,

Its Simple Superb!!,

Thanks,
Myself


Author: kalyan    21 Jan 2009Member Level: Bronze   Points : 0
hai,

it is very nice


thanks
kalyan


Author: HimaBindu Veeramachaneni    22 Jan 2009Member Level: Diamond   Points : 0
thanks kalyan


Author: Dharmaraj    23 Jan 2009Member Level: Diamond   Points : 1
Hi,
Its very nice article. I acquired a lot of information regarding the page life cycle and execution process.
Regards,
Dharma


Author: HimaBindu Veeramachaneni    23 Jan 2009Member Level: Diamond   Points : 0
thanks dharma


Author: Sirghe Mihai    28 Jan 2009Member Level: Bronze   Points : 2
Hey, very good article. Ofcource there are lots of mombo jumbo under the hood, but this article points just the basics.

Still I'd like to add a few things...

The IIS, ISAPI, and the WorkerProcces have 2 main functions:
- forwarding the request to the appropriate http handler (which is created much later)
- instantiating some helper objects (aka the pipeline)

In the case you want to access an .aspx file, the handler for that file is an INSTANCE OF A CLASS DERIVED FROM THE PAGE CLASS. THIS CLASS IS CREATED BASED ON THE DATA YOU PROVIDE INSIDE THE .ASPX FILE AND THE CS OR VB FILES(CODE BEHIND)

After this HTTP Handler is created the pipeline (still don't know esactcly who's responsable) will call the ProccesRequest() method inside this object(handler), and the page lifecicle begins...

For a more in detail explanation of what really happens you can go here:
- http://www.code-magazine.com/article.aspx?quickid=0609061&page=1 (details about how the asp.net engine processes the aspx and the cs files)
- http://www.west-wind.com/presentations/howaspnetworks/howaspnetworks.asp (detailed explanation for the asp.net architecture and request proccessing)


Author: Sirghe Mihai    28 Jan 2009Member Level: Bronze   Points : 2
here is another link, I just found today:
http://msdn.microsoft.com/en-us/library/aa479007.aspx#


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Sorting a ArrayList in C#
Previous Resource: Use Strong Collection Type while design class (Design own Collection data type)
Return to Discussion Resource Index
Post New Resource
Category: .NET Framework


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use