How to listen to IIS shutdown event in ASP.NET

前端 未结 4 1536
小鲜肉
小鲜肉 2020-12-06 09:57

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 ma

4条回答
  •  萌比男神i
    2020-12-06 10:35

    You might not receive any notification that IIS is shutting down. Think of what will happen if the IIS AppPool crashes or what will happen if the server simply loses power.

    You cannot rely on ever hearing about shutdown events. If IIS wants to shut down, it's not necessarily going to notify your application. I recommend you re-think your writebuffering/caching scenario - only keep in memory the data that you can afford to lose.

提交回复
热议问题