加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

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

发布时间:2020-12-15 20:42:12 所属栏目: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
我们有一个应用程序收集计数器统计信息,我们希望在执行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管理器中的应用程序池是
用过的

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读