Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Application_Start block all incoming requests

I have some code that initializes a static singleton class, which is needed by all requests. Therefore I thought I could add it to global.asax Application_Start. Can I be 100% sure that all requests will block while Application_Start is loading to guarantee that all the requests will have access to it?

Thanks a lot Jeeji

like image 287
Jeeji Avatar asked May 05 '10 19:05

Jeeji


1 Answers

Short answer: yes.

Application_Start:

Called when the first resource (such as a page) in an ASP.NET application is requested. The Application_Start method is called only one time during the life cycle of an application. You can use this method to perform startup tasks such as loading data into the cache and initializing static values.

You should set only static data during application start. Do not set any instance data because it will be available only to the first instance of the HttpApplication class that is created.

http://msdn.microsoft.com/en-us/library/ms178473.aspx

like image 110
camainc Avatar answered Oct 12 '22 09:10

camainc