views:

410

answers:

2

In ASP.NET 3.5 (with IIS6), are AppDomains are created for every request? I know that all applications have their own AppDomain under w3wp.exe, but how exactly does the whole AppDomain work?

I was arguing today with a colleague who was trying to convince me that if an ASP.NET application has a static object (or Singleton class), that this object will be shared among all the requests. I think this is false. Am I right? How do I convince my colleague?

Thanks!

+1  A: 

A singleton will exist in the entire scope of the appdomain. Also, all of the requests to your application will go to the same appdomain, so your colleague is actually correct.

Update: The question spurred by curiosity and I found a "singleton" that you can use on a per-request basis. I don't actually recommend that though. If someone needs a per-request singleton then they need to find a more fitting pattern.

DavGarcia
Do you have any idea documentation that I could refer to? Thanks!
Martin
+3  A: 
John Clayton