如何确定ASP.NET应用程序域的生命周期

我们有一个应用程序收集计数器统计信息,我们希望在执行iisreset命令后重置值,这就是全部.

微软称Application_Start是:

Called when the first resource (such
as a page) in an ASP.NET application
is requested. The Application_Start
method is called only one time during
the life cycle of an application. You
can use this method to perform startup
tasks such as loading data into the
cache and initializing static values.

这就是我们目前的做法:

protected void Application_Start(object sender,EventArgs e)
{
    _counters.Get<AutoCounter>("TAS:RequestCount").Reset();
    _counters.Get<AutoCounter>("TAS:RequestTime").Reset();
    _counters.Get<AutoCounter>("TAS:TimeBetweenErrors").Reset();
    _counters.Get<AutoCounter>("TAS:ErrorCount").Reset();
}

但是,它们会以意外的间隔重置.什么决定应用程序域的生命周期何时结束,并在下一个请求中调用此方法?

解决方法

Web应用程序重新启动的原因有很多.此
article包括以下部分列表.

>编辑web.config
> machine.config已编辑
>编辑global.asax
>文件在bin中更改
Web应用程序的目录,或者其中之一
bin的子目录
>创建,重命名或创建目录
在Web应用程序目录中删除
>一个ASP.NET文件(aspx,asmx等)
编辑(因此重新编译)
超过20次,默认设置为
机器配置为元素
命名为numRecompilesBeforeApprestart
>通过各种设置的方式
中的属性
machine.config中的元素,哪个
影响重启/关机
工人过程本身.在Windows上
2003年的时候,没有使用IIS5隔离
模式(默认情况下不使用),
这些元素是
忽略而不是设置
IIS管理器中的应用程序池是
用过的

我的猜测是你的方法很好,但现在你真正想知道的是导致重启的原因以及你是否应该警惕.

dawei

【声明】:淮南站长网内容转载自互联网,其相关言论仅代表作者个人观点绝非权威,不代表本站立场。如您发现内容存在版权问题,请提交相关链接至邮箱:bqsm@foxmail.com,我们将及时予以处理。