Application_Start()

R

RB

Hi!

Is it guaranteed that Application_Start() will only run once per application
start? In other words, what happens if 2 users simultaneousy hit a "fresh"
app? Does ASP.NET know to run only one thread?

Thanks!
RB
 
A

Andy Mortimer [MS]

A usefull link

http://msdn.microsoft.com/architecture/application/default.aspx?pull=/librar
y/en-us/dnnetsec/html/SecNetAP04.asp

You will get an Application_Start for each HttpApplication object

ASP.NET runtime creates as many instances of application class as is need
to process requests simultaneously. For most applications this number is
limited to the number of threads, and would stay in 1-100 range depending
on the hardware, server load, configuration, etc. Application instances are
reused for many requests, and a free list of application instances is kept
during the periods of reduced load. Application instances are utilized in a
thread safe manner, one request at a time. This has important implications:

Users don't need to worry about locking, to access non-static members of
the application class.
Application code can store per-request data in non-static members of the
application class (but not after EndRequest event, as it would keep the
request alive potentially for a long time).
Static members of application class, as of any class, are not thread safe,
and the user code needs to provide appropriate locking around access to
static members.

Andy Mortimer [MS]
Please do not send email directly to this alias. This alias is for
newsgroup purposes only

This posting is provided "AS IS" with no warranties, and confers no rights.
OR if you wish to include a script sample in your post please add "Use of
included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm"
 
K

Kevin Spencer

The Application_OnStart Method is an Event Handler. As such, it will not
fire more than once, when the first request is received. There is no real
"simultaneous" request, although at the speed with which they are processed
it might seem so. Requests are queued.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
Joined
Jun 26, 2009
Messages
1
Reaction score
0
From MSDN

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

The Application_Start and Application_End methods are special methods that do not represent HttpApplication events. ASP.NET calls them once for the lifetime of the application domain, not for each HttpApplication instance.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top