Does Application_Start block all incoming requests
Asked Answered
L

1

9

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

Letterhead answered 5/5, 2010 at 19:39 Comment(0)
G
15

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

Gemstone answered 5/5, 2010 at 19:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.