在ASP.NET IIS应用重新启动时运行Dispose方法 [英] Run dispose method upon asp.net IIS app restart

查看:86
本文介绍了在ASP.NET IIS应用重新启动时运行Dispose方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些代码要在每次重新加载,停止IIS应用程序或其他任何会重置业务类中某些静态属性状态的事件时强制运行.

I have some code that I want to force to run whenever my IIS app gets reloaded, stopped or any other event that would reset the state of some static properties in a business class.

我已经使类实现IDisposable,并尝试添加类析构函数,但是当我将新的dll上传到服务器时,它们都没有运行.我如何从此类内部注册要在应用程序卸载之前运行的方法?

I've made the class implement IDisposable and I tried adding a class destructor, but neither run when I upload a new dll to the server. How can I, from inside this class, register a method to run before the application is unloaded?

推荐答案

我将查看Global.asax中的事件.通常,这是您处理应用程序级事件的地方.以下是一些可帮助您入门的链接:

I would look at the events in Global.asax. This is typically where you will handle application level events. Here are a few links to get you started:

  • http://msdn.microsoft.com/en-us/library/a0xez8f2(v=vs.71).aspx
  • http://www.techrepublic.com/article/working-with-the-aspnet-globalasax-file/5771721

Application_Init或Application_Start可能对您有用吗?

Application_Init or Application_Start might be good for your purposes?

这篇关于在ASP.NET IIS应用重新启动时运行Dispose方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆