Application_Start()

Discussion in 'ASP .Net' started by RB, Feb 12, 2004.

  1. RB

    RB Guest

    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
     
    RB, Feb 12, 2004
    #1
    1. Advertising

  2. 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"
     
    Andy Mortimer [MS], Feb 13, 2004
    #2
    1. Advertising

  3. 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.

    "RB" <> wrote in message
    news:9BTWb.21515$...
    > 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
    >
    >
     
    Kevin Spencer, Feb 13, 2004
    #3
  4. RB

    ericdugas

    Joined:
    Jun 26, 2009
    Messages:
    1
    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.
     
    ericdugas, Jun 26, 2009
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Adrian

    Application_Start not firing at all

    Adrian, Jul 2, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    462
    Adrian
    Jul 2, 2003
  2. Halcyon Woodward
    Replies:
    3
    Views:
    1,018
    Halcyon Woodward
    Jul 16, 2003
  3. Leonardo Gangemi

    Creating diretories on Application_Start

    Leonardo Gangemi, Aug 14, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    343
    Kevin Spencer
    Aug 14, 2003
  4. Max
    Replies:
    5
    Views:
    20,998
    liliancho
    Dec 7, 2011
  5. Bob Johnson
    Replies:
    4
    Views:
    1,026
    George Durzi
    Nov 13, 2003
Loading...

Share This Page