Page view counter

When does Application_Start get called?

Last post 03-03-2007 9:18 PM by flanakin. 3 replies.

Sort Posts:

  • When does Application_Start get called?

    03-03-2007, 1:14 PM
    • Loading...
    • newbie06
    • Joined on 04-14-2006, 5:28 PM
    • Posts 427
    • Points 612

    When does Application_Start get called? I have the following code in the Application_Start function and but it does not seem to run. I would like to Flush the cache on application start up.

    When I debug my program in Visual Studio shouldn't the Application_Start event run everytime I debug???

    void Application_Start(Object sender, EventArgs e) {

    // Code that runs on application startup

    //Flushes the cache on application startup.

    Microsoft.Practices.EnterpriseLibrary.Caching.

    CacheManager c = Microsoft.Practices.EnterpriseLibrary.Caching.CacheFactory.GetCacheManager();

    c.Flush();

    }

     

  • Re: When does Application_Start get called?

    03-03-2007, 1:24 PM
    • Loading...
    • Girijesh
    • Joined on 10-27-2005, 12:04 PM
    • India
    • Posts 652
    • Points 3,086

    Application_Start event runs only once when the application first time runs.

    It run again whenever the application restarts, like change in webconfig etc.

     

  • Re: When does Application_Start get called?

    03-03-2007, 1:31 PM
    • Loading...
    • Haissam
    • Joined on 10-05-2006, 6:25 AM
    • Beirut - Lebanon
    • Posts 5,632
    • Points 37,391

    Check the link below

    Understanding Global.asax

    HC

     

    Haissam Abdul Malak
    MCAD.NET
    | Blog |
  • Re: When does Application_Start get called?

    03-03-2007, 9:18 PM
    Answer
    • Loading...
    • flanakin
    • Joined on 10-05-2003, 3:06 PM
    • Washington, DC area
    • Posts 384
    • Points 1,901

    As the others mentioned, Application_Start is called when the application is first started or, more specifically, when the application receives the first request. Typically, this only happens once, but there are some events which may require the application to restart, such as a change to the web.config file, as mentioned before. To answer your second question, yes, the event is fired before you even get to the UI of the app. If you're not seeing this behavior, make sure your breakpoints are setup appropriately.

    Michael Flanakin | Microsoft Consulting Services
    www.michaelflanakin.com
Page 1 of 1 (4 items)