views:

25

answers:

1

Hi all

I've just read this thread which discusses code to create an NHibernate SessionFactory object statically from a helper class:

http://stackoverflow.com/questions/2362195/ensure-nhibernate-sessionfactory-is-only-created-once

What is the lifecyle of a static member variable in an ASP.NET application? Does it exist as long as the worker process? Or the ASP.NET session? Or something else?

I'm a little confused by it all to be honest.

Thanks

David

+3  A: 

It exists as long as the worker process is alive. These usually recycle once per day (approximately) or if the site is inactive for 20 minutes.

They are unique to an appdomain, and a few more details about the use of static vs Application variables (which are your alternative in ASP.NET) can be found here.

Matthew Steeples
That's really helpful, thank you.
David