Search code examples
c#asp.netiis

How to listen to IIS shutdown event in ASP.NET


I have in my ASP.NET static variable that flushes itself to DB every X insertions. Problem is, if I publish the application , the IIS process is killed with all my static material.

How can I preserve it - or how can I flush it once ASP.NET application is shutting down?

thank you


Solution

  • Global.asax

    void Application_End(object sender, EventArgs e) 
        {
            //  SHUTDOWN CODE HERE
        }