Reputation: 16120
I've just read this thread which discusses code to create an NHibernate SessionFactory object statically from a helper class:
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
Upvotes: 4
Views: 1167
Reputation: 8058
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.
Upvotes: 5