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
    • Member
      615 point Member
    • newbie06
    • Member since 04-14-2006, 5:28 PM
    • Posts 437

    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
    • Contributor
      3,084 point Contributor
    • Girijesh
    • Member since 10-27-2005, 12:04 PM
    • India
    • Posts 652

    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
    • All-Star
      37,391 point All-Star
    • Haissam
    • Member since 10-05-2006, 6:25 AM
    • Beirut - Lebanon
    • Posts 5,632

    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
    • Participant
      1,901 point Participant
    • flanakin
    • Member since 10-05-2003, 3:06 PM
    • Washington, DC area
    • Posts 384

    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)