Rick Strahl's Weblog  

Wind, waves, code and everything in between...
.NET • C# • Markdown • WPF • All Things Web
Contact   •   Articles   •   Products   •   Support   •   Advertise
Sponsored by:
Markdown Monster - The Markdown Editor for Windows

Article: A low-level look at the ASP.NET Architecture


:P
On this page:

Article Link:

http://www.west-wind.com/presentations/howaspnetworks/howaspnetworks.asp

 

Article Summary:

ASP.NET is a powerful platform for building Web applications, that provides a tremendous amount of flexibility and power for building just about any kind of Web application. Most people are familiar only with the high level frameworks like WebForms and WebServices which sit at the very top level of the ASP.NET hierarchy. This article looks at how Web requests flow through the ASP.NET framework from a very low level perspective, from Web Server, through ISAPI all the way up the request handler and your code. See what happens behind the scenes and stop thinking of ASP.NET as a black box.

 

Author:
Rick Strahl

West Wind Technologies

 

Please feel free to use the comments area below to leave any comments or questions related to this article.

 

 

Notes:

I've been sitting on this article for a couple of years now and finally got around to putting it out. The main reason has been that there are still a few open issues that I have not been able to trace completely in the transition from the ISAPI code into the ASP.NET pipeline. How exactly the interfacing works between the ISAPI layer and ASP.NET ISAPIRuntime classes is not exactly clear. It appears that the ISAPI extension directly calls into the runtime instances to instantiate requests.

 

If anybody finds any additional information, or reference material please leave a note here, so I can update the article if possible. It'd be great to complete the cycle and fill in the small missing blanks.  I looked online over the years and asked at Microsoft, but it appears the Microsofties are not keen on sharing this information. Understandable as the implementation may change in the future, but it's still interesting to know how the plumbing works deep down in the bowels of IIS and the Worker Process.

 

 


The Voices of Reason


 

Tom Pester
July 18, 2005

# re: Article: A low-level look at the ASP.NET Architecture

Great read as always but don't expect me to fill in the blanks :s The hint to watermark images with a module is very cool. Thanks!

Bobby John
July 19, 2005

# re: Article: A low-level look at the ASP.NET Architecture

Rick

ur articles r helping me alots.
i'm a beginner in ASP.NET.

ur articles r instilling confidnce in me.

thanks alot.

smiles :-)
bobs.

clayton
July 20, 2005

# re: Article: A low-level look at the ASP.NET Architecture

where you surf dakine asp.net pipeline? is it on da north shore

John Hopper
August 29, 2005

# re: Article: A low-level look at the ASP.NET Architecture

Excellent overview that I haven't found elsewhere. This level of understanding is what distinguishes professionals from script kiddies.

ali
August 29, 2005

# re: Article: A low-level look at the ASP.NET Architecture

very nice effort, really immpressive ...
improved my understanding a lot, thank you, keep writing ...

holle
August 29, 2005

# re: Article: A low-level look at the ASP.NET Architecture

very nice article!

Vitaly
August 31, 2005

# re: Article: A low-level look at the ASP.NET Architecture

Thanks, very nice article!
Little bug: in the final event sequence overview GetApplicationInstance() is a method of HttpApplicationFactory class but not HttpApplication.

fu
August 31, 2005

# re: Article: A low-level look at the ASP.NET Architecture

Good.......very nice article!

Semiotik
August 31, 2005

# re: Article: A low-level look at the ASP.NET Architecture

Excellent article. Thank you very much.

MK
September 01, 2005

# re: Article: A low-level look at the ASP.NET Architecture

WOW

rishi
September 02, 2005

# re: Article: A low-level look at the ASP.NET Architecture

gud article

Iczy
September 03, 2005

# wow

Your article clears up many confusion issues about ASP.NET. Thanks a lot.

dehran ph
September 05, 2005

# re: Article: A low-level look at the ASP.NET Architecture

great article you have, this is actually what im looking for

Sharath
September 15, 2005

# re: Article: A low-level look at the ASP.NET Architecture

Nice article. Will be nice to have a printer friendly version out there. I tried to print it and the matrial gets trimmed out on the right hand side of the page, making it difficult to read.

jon
September 20, 2005

# re: Article: A low-level look at the ASP.NET Architecture

Great article. A lot of low level detail that I've been trying to make sense of but hadn't found the right resource to help me - till now. I still have an unanswered question though. That is, how are instance in the application pool thinned out during slack times. What are the rules for determining which instances should be disposed of? Does the very first instance always become the last instance to end with the application? I'm trying to start a TCP Soap Receiver as part of my Web app and want to assure the instance hosting it remains as long as the application domain does. Any further clarifications would be so much appreciated.

Rick Strahl
September 20, 2005

# re: Article: A low-level look at the ASP.NET Architecture

Application Pool life time is cofigurable at the IIS level. The default is 20 minutes of idle and it releases. If you set this value to a high number or (I think) never then it just stays running along with the ASP.NET AppDomain running inside of it. ASP.NET will release HttpApplication instances if volume gets low but it will leave at least one instance running at all times as long as the AppDomain does not cycle.

King
September 20, 2005

# re: Article: A low-level look at the ASP.NET Architecture

Nice Article ...U r Rock Man..
Post some more articles like that...
Cheers :)

Juliet
September 21, 2005

# re: Article: A low-level look at the ASP.NET Architecture

Regarding the question from Jon (9/20 7:03PM)
do you know if the very first application instance created is always the last one to be torn down? I believe Jon is saying that a specific instance (the first one created) must remain as long as the application domain exists, because the TCP port can only be opened once for all application instances and must remain open. If the instance that opens the port is purged, the listener is gone for all instances.

Rick Strahl
September 21, 2005

# re: Article: A low-level look at the ASP.NET Architecture

Juliet,

I don't think the TCP port is opened by the Application (although we can only guess). This happens at a completely different level deep in the bowels of IIS probaby event before the ISAPI extension gets a hold of the request. Remember multiple Application Pools can serve the same Server IP Address. The HttpApplication instances are disposable and I don't think there's any dependency on them of any sort.

Juliet
September 21, 2005

# re: Article: A low-level look at the ASP.NET Architecture

Thanks for you comments. Jon and I work together and we do in fact want to open a TCP port in our application. Because we weren't aware of the multiple application instances ASP.NET creates, we thought we could open it at application_start and be certain it would remain open. If we knew for sure that the first instance created was the last one to live, we'd be safe with this approach.

Rick Strahl
September 21, 2005

# re: Article: A low-level look at the ASP.NET Architecture

You don't want to attach anything to an HttpApplication instance.

But you don't need that for what you want. It sounds you simply want a permanent location to park a value/object reference and you can do this with a static property and a static constructor. Any static properties you create will exist for the lifetime of the AppDomain. It will cycle when the AppDomain cycles (web.config changes mostly), but then nothing will survive an AppDomain cycle anyway.

That way you're guaranteed one instance for the lifetime of the application.

Juliet
September 21, 2005

# re: Article: A low-level look at the ASP.NET Architecture

Thanks for the advice. A great article by the way.

Jon
September 21, 2005

# re: Article: A low-level look at the ASP.NET Architecture

Rick, thxs for the comments. They help very much. You're right - we can construct our listener class as static Global where it was a local variable in Application_Start.

Sandhya
September 26, 2005

# re: Article: A low-level look at the ASP.NET Architecture

Too good.. excellent - very informative - just what i was looking for to demystify asp.net working behind screen. Hats off to u.

khoa
September 29, 2005

# re: Article: A low-level look at the ASP.NET Architecture

This is a nice article but I wanted to read it offline. How can I print this?
thanks

Selva
October 24, 2005

# re: Article: A low-level look at the ASP.NET Architecture

Great Article !

rekha
October 25, 2005

# re: Article: A low-level look at the ASP.NET Architecture

Very good article
Thanks

Khai Wan
January 04, 2006

# re: Article: A low-level look at the ASP.NET Architecture

Simply excellent. Keep up the good work.

Renuka
January 05, 2006

# re: Article: A low-level look at the ASP.NET Architecture

I have been searching for such a wonderful info on asp.net architecture since 2-3 days and finally found one. Dear Rick, you have contributed such a good one to us, really feeling like saying 3 cheers to you ... Hip hip Hurray ....

Steve Buonincontri
February 09, 2006

# re: Article: A low-level look at the ASP.NET Architecture

It would be nice to get this article in PDF?

Ahmad Lafi
February 10, 2006

# re: Article: A low-level look at the ASP.NET Architecture

Good work! It would be great too if you can tell us where we can find other low-level .Net articles and information

Guruprasad
March 13, 2006

# re: Article: A low-level look at the ASP.NET Architecture

Hi,

Its an great article. But could u please tell me about the different threads behaves accessing my code.

I want to know, like if i have a web service, how the concurrent threads access and use my code and any sync locks i need to implement in my web service ? There are might be several requests at a time accessing my code. How does this affect and if yes, to what extent ??

regards
guru

Rick Strahl
March 13, 2006

# re: Article: A low-level look at the ASP.NET Architecture

If you don't have any global static data there's no problem. ASP.NET manages feeding you a clean thread environment - where just about anything from the request pipeline is is thread safe to access. Each request creates most of the objects specifically for that request so in a way requests run in their own space and you can do as you please in your code.

The main thing you need to watch out for - just like any other multi-threaded application - is global static data (as well as anything you store in the ApplicationState store).

Nazish Ali
March 21, 2006

# re: Article: A low-level look at the ASP.NET Architecture

One of the best Article I have ever read.
Beleive me this article is very much detail and user firendly .this type of article always requried to developer,readers,students etc.
so plz keep this thing same for other technologies like .net framework

andrew
April 04, 2006

# re: Article: A low-level look at the ASP.NET Architecture

Great article! I have a question though.
You never explained how and where HTTPApplicationState object is created and attached to HTTPConext and HTTPApplication object. I'd really appreciate your input on this.

Sid
April 12, 2006

# re: Article: A low-level look at the ASP.NET Architecture

Nice article! Gives a very fair explanation of the ASP.Net architecture. In the last section, HTTP Handlers, I think you should explain how web.config can be used to connect to a particular handler with the help of the <httpHandlers> tag.

Thanks!

Pravin Thakur
April 24, 2006

# re: Article: A low-level look at the ASP.NET Architecture

Its really low level.. Good one thanks.....

Deepak
May 03, 2006

# re: Article: A low-level look at the ASP.NET Architecture

A great & well done effort to help the community of DOTNET Starters [like me :)].
Nothing can be more informative & explanatory than this.
Hats off to you for this Excellent Job.

Simon
May 05, 2006

# re: Article: A low-level look at the ASP.NET Architecture

Great article - Finally something that does more than scratch the surface!

Muthu
May 15, 2006

# re: Article: A low-level look at the ASP.NET Architecture

Rick, This article is really an impressive one.. Keep writing similar kind of articles !

# re: Article: A low-level look at the ASP.NET Architecture (great)

Very informative,
But unfortunately i could not understand,I need to go through once again(because i need to know more about the technical terms of low-level in IIS and .net)

However the artical is very good

er.surjit@gmail.com
June 20, 2006

# re: Article: A low-level look at the ASP.NET Architecture

greate man, its tooooooooo good

Niko_Quebec
July 03, 2006

# re: Article: A low-level look at the ASP.NET Architecture

OutStandind article !
thanks a lot

Rob Frohwein
July 18, 2006

# re: Article: A low-level look at the ASP.NET Architecture

Thanks for the good article.
One question:
Is it possible witht VS.NET to create
a standalone soap server, i.e. without
using IIS?

Rob

Rick Strahl
July 18, 2006

# re: Article: A low-level look at the ASP.NET Architecture

Yes... You can host the HttpListener in an application as shown here:

http://west-wind.com/weblog/posts/3748.aspx

And you can then host the ASP.NET Runtime in this application:

http://www.west-wind.com/presentations/aspnetruntime/aspnetruntime.asp

Samuel Johnlee S
July 19, 2006

# re: Article: A low-level look at the ASP.NET Architecture

Really, this article is very useful for beginners and experienced developers. One go thru this, we can learn a lot in asp.net architecture. thanks

Krishna
August 09, 2006

# re: Article: A low-level look at the ASP.NET Architecture

Excellent one, I forwarded your article to almost all of my friends including some of the MVPs.As you said the transition from the ISAPI code into the ASP.NET pipeline is bit dodgy; only god (Microsoft guys) knows what's happening there. Please update us more on this. Email ID: krishire@hotmail.com

Martin Möbius
August 09, 2006

# re: Article: A low-level look at the ASP.NET Architecture

Thanks a lot, a thoroughly walk through the ASP.net runtime.

Rick Strahl
August 09, 2006

# re: Article: A low-level look at the ASP.NET Architecture

Krishna, most of the core plumbing changes in IIS 7 since IIS 7 has an integrated pipeline that fires .NET code natively.

Once we get closer to the 7.0 release I'll probably do some thing similar for IIS 7.

Andy Sen
August 10, 2006

# re: Article: A low-level look at the ASP.NET Architecture

A very informative article indeed. We've been facing some issues lately where we are using legacy .NET libaries (originally designed for use in a winform app) in our web app. The problem occurs because of quite a few static classes/variables used in these DLLs which tend to mess up when used in a web context (multiple users hitting the site). Is there any way to ensure that for each request (or each web session) these DLLs are loaded in a separate process/AppDomain? (anything to preserve the data sanctity in the legacy code). I understand this approach is not the best, but we can live with the overhead/performance issues for now till the libraries are re-written. Any pointers would be appreciated. Thanks.

David
September 06, 2006

# re: Article: A low-level look at the ASP.NET Architecture

Where do subsequent session requests queue? eg. i always thought in double-submit scenario that the 2nd submit queues somewhere until the first completes.

David Smith
September 07, 2006

# re: Article: A low-level look at the ASP.NET Architecture

I've realized the answer to my own qtn yesterday. A 2nd request is blocked due to synchronization on the Session object (assuming page EnableSessionState setting).

Kola
September 13, 2006

# re: Article: A low-level look at the ASP.NET Architecture

Your article is top in Google search, when i search for "asp.net architecture".

Read a lot of articles before on architecture, never come across an article like this.

Keep it up...! Keep posting articles.

Finally, Thanks a lot.

Ravi Srinivas
September 22, 2006

# re: Article: A low-level look at the ASP.NET Architecture

This article is very nice and helped me a lot
Hope you will have much more to publish in .net 2.0

thanks

Ravi

Rick Strahl
September 29, 2006

# re: Article: A low-level look at the ASP.NET Architecture

Ravi yes you can change the response in several ways. You can use a Response Filter (if you can modify content on the fly as it's written) or you can capture the output stream after the handler completes capture it modify, clear the existing response and then write it back out again.

Recent reading
October 03, 2006

# Recent reading: A low-level Look at the ASP.NET Architecture


Rick Strahl's Web Log
October 15, 2006

# Add a Web Server to your .NET 2.0 app with a few lines of code - Rick Strahl's Web Log

.NET 2.0 includes a very useful and more importantly easily integrated HttpListener class that makes it very easy to add a Web Server to your own applications. Can you say quick communication between two apps?

# a-low-level-look-at-the-asp at Programmers Heaven

Free programming files, links, articles, tutorials, source codes, utilities, ASP, .NET, C/C++, .NET, C#, ASP.NET, XML, Visual Basic, Delphi, Java, Pascal, Assembler and other tools for programmers.

otto
October 26, 2006

# re: Article: A low-level look at the ASP.NET Architecture

Hi, Rick:
firstable, very good article! It has been very useful for me.
I want to ask you something. Imagine that you hace a configuration file called config.config. Instead of having <appSettings> values in application web.config file, you have them in this file. In web.config you have the link to this file: <appSettings file="C:\config.config" />.
When you make a change in web.config, tha AppDomain is restarted automatically so every HttpApplication object can see that changes. But, what happens if you modify in my case the config.config file? Does the AppDomain have notice of these changes and it´s restarted automatically? If the answer is no, what can I do to make the changes visibles for all HttpApplication objects?
Thanks a lot!

Rick Strahl
October 26, 2006

# re: Article: A low-level look at the ASP.NET Architecture

I can't remember the exact details now, but you can use external files and have changes in them also cause AppDomain restarts. I think the above syntax is all you need, but there may be another switch you need to specify.

aromr
November 19, 2006

# URL Rewrite question

Hey, great article.
but I got a question which lead me into ur article in first place.
I want to do url rewriting.
example
http://localhost/products/myproduct ==> http://localhost/somepage.aspx?cat=products&prod=myproduct


I used to do so using ISAPI rewriter, but now I need to do this witout it.
I tried HttpModule.
but first I removed all files handlers from IIS (5.0) and I left only one handler associated to all extensions aspnet_isapi.dll .
the problem is ,when I request the fake URL IIS issues 404 and I can not caputer the request.( as there is no folder named "produects")


how can I force the IIS to send me any requst regardless the requested resource exists or not.
I hope u note that all I will do within a handler or amodule is to rewrite the url using context.RewritePath(string newUrl);

also I want the ASP.NET to continue serving the new URL i.e if the request was for an aspx page, the page factory handler is invoked.

thanks in advance

Krish
November 29, 2006

# re: Article: A low-level look at the ASP.NET Architecture

Hi Rick,
I read the below stuff from the MSDN article

When ASP.NET receives the first request for any resource in an application, a class named ApplicationManager creates an application domain. Application domains provide isolation between applications for global variables and allow each application to be unloaded separately. Within an application domain, an instance of the class named HostingEnvironment is created, which provides access to information about the application such as the name of the folder where the application is stored.

Your comments on this please...

Yogendra
December 08, 2006

# re: Article: A low-level look at the ASP.NET Architecture

Great Article! Kudos.
I am interested in knowing as to how the http pipeline distinguishes between normal request and postback request?

Waiting for your comments. Thanks inn advance

Rick Strahl
December 08, 2006

# re: Article: A low-level look at the ASP.NET Architecture

Not sure what you mean? HTTP Verb will be POST in any Postback.

Jack Ma
February 14, 2007

# re: Article: A low-level look at the ASP.NET Architecture

This article always gives me fresh and exiting gift every time I come back to read it again!

Thanks a lot, Rick Strahl!


February 25, 2007

# Bily - 博客园


arulrajv
February 28, 2007

# re: Article: A low-level look at the ASP.NET Architecture

superb article , it gives solid foundation for the web application.
tanq
Rick Strahl!

Puneet Dhingreja
May 15, 2007

# re: Article: A low-level look at the ASP.NET Architecture

indeed a brilliant article..

# DotNetSlackers: Article: A low-level look at the ASP.NET Architecture


Avinash
August 08, 2007

# re: Article: A low-level look at the ASP.NET Architecture

Brilliant article!!
I was searching for this kind of article which gives somewhat low level working of request handling. Really great stuff.

Thanks,
Avinash

techna
August 22, 2007

# re: Article: A low-level look at the ASP.NET Architecture

Splendid article! Just what I was looking for.. Hats off to you for this gem!

Thank you.
Chetan

Siddharth Srivastava
September 06, 2007

# re: Article: A low-level look at the ASP.NET Architecture

Nice article. I have a question here: IIS5.x working is clear. But in IIS6, how and when in the worker process (w3wp.exe) is actually created? I know for the fact that http.sys dispatches http request to ISAPI extension, which is actually loaded in w3wp.exe. So how kernel driver to dispatch anything to ISAPI, first the process needs to be loaded. So when w3wp is created?

Thanks.
-Sid.

Rick Strahl
September 06, 2007

# re: Article: A low-level look at the ASP.NET Architecture

That's the job of hte IISADMIN service. http.sys routes through the admin service when the worker process doesn't exist yet. Once created http.sys keeps track of which worker processes are active directly and calls into them directly.

sankar
September 14, 2007

# re: Article: A low-level look at the ASP.NET Architecture

which will differentiate module and handler in this request

Ajit Kumar
September 18, 2007

# re: Article: A low-level look at the ASP.NET Architecture

Rick you are great !!!

Your article is also great.I had never found any good article on this topic as you have written.
I think this article is must for all the ASP.NET developer.

Lot of thanks.

Yours
Ajit Kumar

zeronet
September 23, 2007

# re: Article: A low-level look at the ASP.NET Architecture

I had never read any good articles than yours before. Thanks a lot.

Yours
zeronet

zeronet
September 23, 2007

# re: Article: A low-level look at the ASP.NET Architecture

well, I had sent e-mail to you twice and only got no success message. I want to ask for you, I want to translate your article to another language, can I do it freely and if you don't allow that I will add the link in my blog site to your article and make a short piece of writing for intruducing you and your article. well, thanks again for that's great article. It help me more.

yours
zeronet

Vivek A R
October 17, 2007

# re: Article: A low-level look at the ASP.NET Architecture

Hi Rick,

This is indeed an excellent article.

Thanks
Vivek

Nikki
October 29, 2007

# re: Article: A low-level look at the ASP.NET Architecture

Great Article, Is anything changed in ASP.NET 2.0 if yes when are you going to update the article? Just being greedy.

Thanks

Robert
November 14, 2007

# re: Article: A low-level look at the ASP.NET Architecture

Very useful Article. Thanks a lot

Robert

Guru
November 30, 2007

# re: Article: A low-level look at the ASP.NET Architecture

Hi,

This is the best artical i ave ever read abt asp.net archetecture.

Looking forward for future release artical from u.

Guru

Preeti Reddy
December 28, 2007

# re: Article: A low-level look at the ASP.NET Architecture

This is an awesome article. Explained really well and cleared lot of gray areas in my head.
Thank you so much.

Regards
Preeti Reddy

Jakub
February 22, 2008

# re: Article: A low-level look at the ASP.NET Architecture

Excellent article. Thanks!

Anonymous
February 25, 2008

# re: Article: A low-level look at the ASP.NET Architecture

This article loooked great.
But its tooo complicated. May be the language used itself is complicating the topic.

While explaination, Either same sentences keep repeating or suddenly there is a jump to some new topic which comes outa nowhere.

At the end of the article webforms and http handler is being compared. I have no idea why was that required.

VJ
February 26, 2008

# re: Article: A low-level look at the ASP.NET Architecture

Awesome article never see an article so good. Great job Rick.

Minor print issue with the article, words in the right side of the printed document are yanked off.

HJ
February 26, 2008

# re: Article: A low-level look at the ASP.NET Architecture

Great article. I was wondering if you are planning similar article for IHttpAsyncHandler where ASP.NET pages perform Asynchronous operations. The delima is:
1.) How are threads (worker, IO, threadpool) managed in Async environment.
2.) If web application has global static data that is being used e.g. static variable declared in Global.asax.cs file, what happens to this variable when the AppDomain is recycled, is this static data re-initialzed when a new AppDomain is created?
3.) What happens if the HttpResponse is ready to be sent while in middle of IAsyncResult BeginProcessRequest(....) method execution. Because of the requirement of IHttpAsyncHandler, the BeginProcessRequest(.....) has to return IAsyncResult, how do you signal ASP.NET that HttpResponse is complete (via e.g. IsComplete property or calling the callback) and ready to be sent, because you are still in middle of executing the BeginProcessRequest and have not yet returned the IAsyncResult. How does thread processing work in this scenario?
4.) In some load runs of my web application, the memory dump has shown some "Dead Threads", I was wondering are these threads "dead" because ASP.NET didn't have a lot of requests and it tried to remove HttpApplication objects and the MaxIoThreads assigned to this AppPool or there is something wrong with my web application that is resulting in the dead thread.
----------------
Is there a way I could get notified when you respond to the queries above or do I need to visit the website to check for updates?

Thanks.
HJ

Ashutosh
March 03, 2008

# re: Article: A low-level look at the ASP.NET Architecture

Hi Rick,


Really covered almost all the portions from page request to respond and what happen behind the seen. Complete connected chain.

Really great article, please keep going like that and cover other topic also in deep like this.


Thanks again for such a good information.

Ashutosh

Terry Yoder
March 13, 2008

# re: Article: A low-level look at the ASP.NET Architecture

Hi Rick,

We have a question about appdomains and how they determine where shadow dlls are copied to. We are currently experiencing some strange behavior that seems to point to several web applications pointing to the same location to retrieve the shadow dlls.

We have a Win2k3/IIS6 web server that hosts multiple asp.net 2.0 web applications in a testing environment. Our web applications are file-based web sites (not Web Application Projects), therefore we publish the bin plus all code-beside files. Three of these web applications are actually different versions of the same web application (branches of the same baseline app). Also these three web applications all run in their own application pool and are simultaneously running for parallel testing. They all resolve to the same url (ie http://subdomain.ourwebsite.com) and our testers determine which site they are testing via their local Hosts file.

The strange behavior that we experienced occurred when we promoted new code to one of the sites. This site had some new styling via css. Afterwards, some of the pages in that same site were displaying with the older css styles. While it seems like a possible client-side caching issue, we do not believe this to be the case, because clearing the browser cache did not solve it. We also experienced it on different machines using IE 7 and Firefox. The only solutions to this issue were to either recycle all sites or just stop the other two sites (the two sites that we did not promote code to).

We surmise that this behavior is related to the asp.net 2.0 shadow copy feature. Given the fact that we are running these three parallel sites, is it possible that the shadow copy feature is intermingling the shadow files and thus the CLR is loading the wrong assemblies?

jatin
March 28, 2008

# re: Article: A low-level look at the ASP.NET Architecture


Greak work.Most comprehensive article I ever read on Asp.Net Architecture.


Keep going ..

Regards
Jatin

Mike
March 29, 2008

# re: Article: A low-level look at the ASP.NET Architecture

I tried your example using a FireFox browser and IE and the Application Id and the Thread Ids are different between the 2 browers with each subsequent request. Doing this was easier than trying to run the example from 2 separate machines.

Pritesh
April 03, 2008

# re: Article: A low-level look at the ASP.NET Architecture

It's absolute fun to dig inside any technology...

This is article just proves that.

Truly appreciate ur work Rick.

Rgds,
Pritesh

Karpacz
April 17, 2008

# re: Article: A low-level look at the ASP.NET Architecture

I will start learn ASP next month

darshan
May 30, 2008

# re: Article: A low-level look at the ASP.NET Architecture

hie this is very gud article for basic understanding....

like wise the same i am facing issue in my web page.
my web page just simple its hitting to database and returning one random number from there i have hosted this at iis 6.0 and when i am going to hit 10 hits / sec than page is giving proper response when i m going to hit 20 hits / sec the page is going to give sometimes response like connection time out. when i start iis than its giving again proper response.
what should i need to change in page or in iis 6.0 setting so page can give faster respones every time even i hit for 20 hit/ sec or more.

you can mail me on darshanthacker@gmail.com

thanx in advance.

My crystal
May 31, 2008

# re: Article: A low-level look at the ASP.NET Architecture

impressive article! That is what a architect needs. I have a question when i do my test. I add a "step" indicator in the Global class. Here is the code:

public int step = 0;
void Application_Start(object sender, EventArgs e)
{
step++;
System.Web.HttpContext.Current.Response.Write(step.ToString() +":Application_Start" + " HttpApplication instance's Hash Code:" + this.GetHashCode());
}

void Application_BeginRequest(object sender, EventArgs e)
{
step++;
this.Response.Write("<hr>" + step.ToString() + ": Application_BeginRequest" + " HttpApplication instance's Hash Code:" + this.GetHashCode());
}

The broswer display the following:
1:Application_Start HttpApplication instance's Hash Code:36191204
1: Application_BeginRequest HttpApplication instance's Hash Code:56435330

Why the HttpApplication instance executing Application_Start() is not the same HttpApplication instance executing Application_BeginRequest()?

Any further clarifications would be appreciated.

My crystal
May 31, 2008

# re: Article: A low-level look at the ASP.NET Architecture

hi,every one.
I have another question about HttpApplication. In reflector i find that HttpApplication's IHttpHandler.ProcessRequest as following:
void IHttpHandler.ProcessRequest(HttpContext context)
{
throw new HttpException(HttpRuntime.FormatResourceString("Sync_not_supported"));
}
and it implements IHttpAsyncHandler.BeginProcessRequest & IHttpAsyncHandler.EndProcessRequest. It seems that HttpApplication processes request asynchronously. But since it's the the web form that really does the hard work of processing the request, so i think there is no need to for HttpApplication to processing the request asynchronously.
Thank you for your clarifications.

Pradeep Kumar Mishra
June 12, 2008

# re: Article: A low-level look at the ASP.NET Architecture

It's very nice article man. Thanks a lot for all the effort you put in writing this.

vinod kumar
July 03, 2008

# re: Article: A low-level look at the ASP.NET Architecture

Hi Rick,

honestly i say u have done great job .
u have helped me lot .
i wish if u continue more on handlers and modules as this article doesn't belong to lengthy boring articles.

Great job

shilpa mahangade
July 04, 2008

# re: Article: A low-level look at the ASP.NET Architecture

Simply superb article. Very much informative
Thanks a lot

Ab belt
July 06, 2008

# Ab belt

Interesting article.

Bhuvan
July 06, 2008

# re: Article: A low-level look at the ASP.NET Architecture

Hi,,

Finally I've reached the right place to understand asp.net architecture..thiis article is well-structured....it'll be very useful for beginners to catch up the concepts easily...

michael
July 31, 2008

# re: Article: A low-level look at the ASP.NET Architecture

Hey. I thought you might be a good resource for a question. I have a page that gets posted back during the normal life cycle. I also have a page that gets posted back during its normal lifecycle. The kicker is that both requests can come in at the same time. Does Asp.Net handle each request on independant threads requiring me to lock my Database connection. Or are the requests queued?

domain name transfers
September 18, 2008

# domain name transfers

Several years ago, when I was actively playing Age of Mythology online, I met a guy who called himself Nemesis. I only know that he was from North Dakota. He knew more about web hosting more than I did at the time. He was hosting a website through his home computer. He mentioned that he purchased his domain at. And he recommended it if I ever needed to buy domains. A few years after, we needed to register a domain of our own. So we went to cheap- domainnames. com. The price of a. com domain was US 8. 10. ...

kavitha
September 30, 2008

# re: Article: A low-level look at the ASP.NET Architecture

Really nice article to understand the asp.net architecture. Expecting more articles regarding in-depth concepts in asp.net runtime execution life cycle.

bekz
November 10, 2008

# re: Article: A low-level look at the ASP.NET Architecture

hi rick,

Excellent article which is well written and concise. the figures helped in understanding better.

You could have elaborated the HTTPApplication a bit in helping the audience getting a better interpretation, still now i can't imagine an HTTPAppplication very well something by giving sample like SPHttpApplication or so.

Wyszukiwarka mp3
November 10, 2008

# re: Article: A low-level look at the ASP.NET Architecture

This article is really interesting! Thanks!

Shailesh
November 26, 2008

# re: Article: A low-level look at the ASP.NET Architecture

its really a gr8 article...a well defined and explanatory...thanks rick
like to see more such articles in future....

sandip patil
November 30, 2008

# re: Article: A low-level look at the ASP.NET Architecture

WOW......flow is very very nice.....great!!!!!!!!!!!!!!!!!!!!!!!!!!!

web hosting
December 16, 2008

# web hosting

Of course, you can always change your name (though not that easily) , but typically the name you\'re born with, is the name your stuck with.

Kostenloser WEB Space
December 25, 2008

# Kostenloser WEB Space

Archiv aus Deutschland und aller Welt mit Informationen und Links zum Empfang von Webradio, Web-TV

Patel Ashish
December 29, 2008

# re: Article: A low-level look at the ASP.NET Architecture

hi
this good article and I read it when I will get time
it's good for person who become expert into Asp.net tech

Gurudatt
January 26, 2009

# re: Article: A low-level look at the ASP.NET Architecture

Hi Rick,
Primarily it was a good article.
Even though i am very new to ASP.Net, i got to know many things. I have a question though.
Question -
The worker processes ASPNET_WP.EXE (IIS5) and W3WP.EXE (IIS6) host the .NET runtime which is the CLR(to my understanding). Now to my knowledge when a asp.net page is requested, the sourcecode in the page get compiled by c# or vb.net compiler to managed code and then converted by JIT compiler to executable(dll). At this point, the DLL is instantiated and the output(asp.net page) is generated and sent to the web browser.
NOW WHERE DOES IT HAPPEN IN THE ABOVE SCENARIO?
Thanks

Jay
February 02, 2009

# re: Article: A low-level look at the ASP.NET Architecture

I feel the article is still confusing.
It would be better if it is explained with an example request for both iis 5 and 6.
It should be explained in the context of two requests from two different applications.

Mangesh
May 14, 2009

# re: Article: A low-level look at the ASP.NET Architecture

Your article is very nice.
But i Have one question.
Suppose I have two web application hosted on my IIS server.
So how many worker process will be created for these application.
It will be two different work processes for each web application or one work process for two web application separated by appDomain. ?

zihotki
June 29, 2009

# re: Article: A low-level look at the ASP.NET Architecture

Thanks for really useful article. It saved me at least one day =). Hope you'll update it for IIS 7 too. Thanks a lot!

zfg
July 20, 2009

# re: Article: A low-level look at the ASP.NET Architecture

A very nice article , it helped me a lot. Thanks a lot!

susmit roy
August 09, 2009

# re: Article: A low-level look at the ASP.NET Architecture

Hey Rick,

It is a nice article indeed. But there are certain things tht still I cant visualize yet. Supoose I ve a web application and I ve configured it in IIS as a virtual directory and also I ve created and configured an app pool. My application has been defined to remain in tht app pool.
When and httprequest arrives to IIS, how the worker process will act? Will I ve any seperate worker process because I ve hosted the application in a newly created app pool or any existing worker process of another app pool will serve this request? If I add another application in this pool then will this application also have the same worker process?

Sharad
September 22, 2009

# re: Article: A low-level look at the ASP.NET Architecture

Hey ...this is something which I have never seen anywhere else on web,Gre8 job Rick ...thank you very much for giving such a useful insight in ASP.NET architecture

Vishnu
October 29, 2009

# re: Article: A low-level look at the ASP.NET Architecture

Excellent article. Now I can visualize how request and response are processed in IIS. Thanks a lot man ...

G
November 26, 2009

# re: Article: A low-level look at the ASP.NET Architecture

Thanks for the article, really good job! You've make my live easier.

Srinivas
December 01, 2009

# re: Article: A low-level look at the ASP.NET Architecture

one of the best articles for any beginner in asp.net
thanx a ton

Tarik
December 25, 2009

# re: Article: A low-level look at the ASP.NET Architecture

This article is really awesome. Thank you very much for your hard work on this article.

Manjula
February 08, 2010

# re: Article: A low-level look at the ASP.NET Architecture

HI Rick
Its a wonderful artical.

Thanks

.NET Technical articles
February 11, 2010

# re: Article: A low-level look at the ASP.NET Architecture

Excellent article Rick! This is very detailed and informative..
Nice work...

Sandeep Aparajit
http://sandeep-aparajit.blogspot.com

Alek
March 03, 2010

# re: Article: A low-level look at the ASP.NET Architecture

very nice article

rajesh
March 04, 2010

# re: Article: A low-level look at the ASP.NET Architecture

Hi Rick

When we migrate applications from one platform to another it is a common requirement that, the urls from old application for eg. perl should be mapped to the new one. We normally use IIS Http redirect feature to do this.

What I've seen with IIS6 is that, if the url does not contain any page extension like aspx, then IIS doesn't know how to handle such requests and we get 404 error. HttpModule also won't work in this case. In IIS7, in integrted mode it is possible to intercept requests before it reaches the asp.net pipeline and hence we can redirect such requests to the corresponding Urls. Do you know how the same can be done in IIS6, without going with the http redirect feature? Do I need to write a custom ISAPI filter?

Thanks

Rajesh
March 12, 2010

# re: Article: A low-level look at the ASP.NET Architecture

Superb Article...so much depth and with ease it makes you understand.

Pankaj Gupta
March 23, 2010

# re: Article: A low-level look at the ASP.NET Architecture

Very detailed,well organized and well presented article.
Thanks for the enlightenment!
-Pankaj

Mukesh
March 31, 2010

# I have some Question

Hi Rick,

Here is Mukesh.I read your article. its fantastic.I always wanted to know the basic story behind .NET working..and I got it...Many many thanks to you...can you send me article, videos, related to internet, .net,

And one thing that I like to know, How can i deploy my website over internet..i mean the basic process for webhosting, and what is DNS server , where is it and how it works. and where r DNS.. Please Rick , Help me.....

I m really your big FAN...And I hope u will never make me Melancholy...

Thanks Rick

vijendra kushwaha
April 02, 2010

# re: Article: A low-level look at the ASP.NET Architecture

Hi,
great article, very good content, thanks for such great article

shijo
April 09, 2010

# re: Article: A low-level look at the ASP.NET Architecture

Hi rick,

Its a very great article.....and it helped me very much....Thanks u......

siva
April 15, 2010

# re: Article: A low-level look at the ASP.NET Architecture

It's nice article..when an asp.net page requested it will check for the cached version of the page present in the memory or not....where it happens?

ruju
May 03, 2010

# re: Article: A low-level look at the ASP.NET Architecture

gr8 article...it has helped me to understand the HTTP Handlers and Modules, which were not understood earlier. thanks a ton.

krishna
May 10, 2010

# re: Article: A low-level look at the ASP.NET Architecture

Hi Rick,
You said you will release an updated version for IIS 7., do you have any link for it.

Thanks,
Krish.

# re: Article: A low-level look at the ASP.NET Architecture
by Rick Strahl August 09, 2006 @ 11:22 am
Krishna, most of the core plumbing changes in IIS 7 since IIS 7 has an integrated pipeline that fires .NET code natively.

Once we get closer to the 7.0 release I'll probably do some thing similar for IIS 7.

EduardR
June 02, 2010

# re: Article: A low-level look at the ASP.NET Architecture

Excelent! This article should be mandatory material for anyone designing web aplications within .net framework.

Waiting for the IIS 7 chapter!

Thanks very much.

EduardR
June 02, 2010

# re: Article: A low-level look at the ASP.NET Architecture

About the chapter about IIS7 I think it would be interesting an explanation about the services IIS 6 provides (like IIS authentication, http headers, content rating, etc...) in general (not only to .Net), how the ISAPI extension and filters apply, and so on. And finally how things are changed in IIS7.

Sanga
June 06, 2010

# re: Article: A low-level look at the ASP.NET Architecture

Very useful article.

Amrita
September 20, 2010

# re: Article: A low-level look at the ASP.NET Architecture

Wonderful Presentation. Detailed :) Thank you Rick

Chandresh Makwana
October 07, 2010

# re: Article: A low-level look at the ASP.NET Architecture

An excellent description of sequence and collaboration of objects while processing an HTTP web request in ASP.NET runtime. Many hidden aspects of IIS also are clear now. Thanks for publishing it.

aleem
November 29, 2010

# re: Article: A low-level look at the ASP.NET Architecture

best asp.net in decade

Marcelin
March 16, 2011

# re: Article: A low-level look at the ASP.NET Architecture

Wonderful explanation for the web page request processing... It wont forgot once we go through full. Nice dude..

Souvik Maiti
April 21, 2011

# re: Article: A low-level look at the ASP.NET Architecture

Nice article ... provides true insight of how asp.net works which is mystry to even very skilled programmers :-)

Alexey Auslender
May 31, 2011

# re: Article: A low-level look at the ASP.NET Architecture

The most detailed explanation I've ever seen.Thanks a lot.I guess there is a mistake in this row :Typical default handlers in ASP.NET are Authentication, Caching for pre-processing and various encoding mechanisms on post processing.
It should be Typical default moduls

Bradley Ward
August 11, 2011

# re: Article: A low-level look at the ASP.NET Architecture

Excellent article! I found this article after I started searching to find out the very earliest point in an ASP.Net application that I could insert some of my own code. This article gives me lots of lower level info, but I'm still not sure if it contains what I am looking for. So let me explain.

My ASP.Net application uses Oracle, so it references the Oracle.DataAccess.dll and the Oracle.Web.dll dll's.

While I am pretty sure I know what is causing the exception I show below (32 bit dll vs 64 bit dll), my approach to handling errors in code is to first make sure that I catch the error in an exception handler somewhere and provide not only the information from the exception, but also provide information on what my experience has taught me the problem really is, and what the person or system administrator should do about it.

That said, the problem is that the exception I show below occurs before control ever gets to the Application_Start() method, therefore I cannot do something like use the AppDomain.UnhandledException to trap this exception.

Looking at the stack trace below, do you or anyone else reading my post know of a way I can intercept control early enough in the startup of my ASP.Net application that I could then trap this exception?

Thanks,

Brad



[BadImageFormatException: Could not load file or assembly 'Oracle.DataAccess' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +39
System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks) +132
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +144
System.Reflection.Assembly.Load(String assemblyString) +28
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +115

[ConfigurationErrorsException: Could not load file or assembly 'Oracle.DataAccess' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +1023
System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +346
System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +85
System.Web.Configuration.AssemblyInfo.get_AssemblyInternal() +54
System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +274
System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() +64
System.Web.Compilation.BuildManager.CallPreStartInitMethods() +235
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +1109

[HttpException (0x80004005): Could not load file or assembly 'Oracle.DataAccess' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +762
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +156
System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +357

Eduard
August 19, 2011

# re: Article: A low-level look at the ASP.NET Architecture

Can't wait for the IIS7 version!

In particullar I found quite confusing the managedHandler httpmodule precondition... Independently of the httpApplication event registrations within the httpmodule's Init function code, the registered functions would not be called if the request is "non-managed handler"?

satvant
October 12, 2011

# re: how Run asp program with iis pls give the complete procedure

how Run asp program with iis pls give the complete procedure
we want and tried to connect asp page with iis but unable to do this.

Stan
February 15, 2012

# re: Article: A low-level look at the ASP.NET Architecture

I wonder how many managed heaps and garbage collectors are there, one per worker process?

Rick Strahl
February 16, 2012

# re: Article: A low-level look at the ASP.NET Architecture

There's one Garbage Collector per CLR instance running inside of a process. There's one set of heaps per process as well, but the heaps are separated per AppDomain. The same rules apply to an IIS worker process as they do to any other.

There's more info here in this oldie but goodie:
http://msdn.microsoft.com/en-us/magazine/cc163791.aspx

James A
February 29, 2012

# re: Article: A low-level look at the ASP.NET Architecture

I know you get asked this alot, but did you ever do an update article for IIS 7? GREAT article BTW!!!

Hardik
June 15, 2012

# re: Article: A low-level look at the ASP.NET Architecture

Thanks a lot for the article. very detailed explanation. Though sometimes it felt like a marry-go-round trip, The listing (summary) provided at the end of it made it plain and simple.

Thanks again

Richard
July 31, 2014

# re: Article: A low-level look at the ASP.NET Architecture

An excellent article and still highly informative here and now in July 2014. Obviously some of the end bits have changed with new MVC Handlers etc but still I was able to follow along using referencesource.microsoft.com and much of the core methods still spot on which says something about the stability of the framework I guess.

I will be reading a couple of "top up" articles next on codeproject etc to bring into line with IIS 7.5 -8 but I'm still struggling to find articles of this quality and depth when it comes to how security and identity are handled/injected throughout the request pipeline.

Something similar to this article discussing security from http.sys all the way to NTFS and back would be ideal. Any thoughts?

Thanks again either way. I know these articles take quite a bit of time to mangle together.... specially so waay waay back in '05 I bet.

Veverke
March 15, 2015

# re: Article: A low-level look at the ASP.NET Architecture

Excellent and a must read article. I share the philosophy that understanding the inner workings of things may contribute greatly for further creations - besides the fact the seeing the big picture gives lots of satisfaction.

A must read !!!

West Wind  © Rick Strahl, West Wind Technologies, 2005 - 2024