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

ASP.NET中是否只有一些初始化区域只运行一次?

发布时间:2020-12-16 07:31:28 所属栏目:asp.Net 来源:网络整理
导读:我有一段代码,我想在我的网站首次加载时运行一次. 它基本上是另一个模块的静态初始化. 当网站首次提供给客户端时,是否有一些事件可以挂钩? 它甚至不需要每次会话,只需首次加载到任何客户端. 我正在使用vs2010,.net 4.0,asp.net 4.0 解决方法 您可以使用Appl
我有一段代码,我想在我的网站首次加载时运行一次.
它基本上是另一个模块的静态初始化.

当网站首次提供给客户端时,是否有一些事件可以挂钩?
它甚至不需要每次会话,只需首次加载到任何客户端.

我正在使用vs2010,.net 4.0,asp.net 4.0

解决方法

您可以使用Application_Start事件.

请参阅MSDN ASP.NET Application Life Cycle Overview

Application_Start is 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.

(编辑:李大同)

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

    推荐文章
      热点阅读