什么时候preApplicationStartMethod居然被触发运行? [英] When does PreApplicationStartMethod actually get triggered to run?

查看:103
本文介绍了什么时候preApplicationStartMethod居然被触发运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用WebActivator preApplicationStart方法,究竟是什么触发绑定此方法来运行?当IIS7已经启动了应用程序池?当第一请求发送到网络服务器?别的东西?如果你有答案,请你也提供了一个参考,你得到这个信息?

When using the WebActivator PreApplicationStart method, what actually triggers the methods bound to this to be run? When IIS7 has started the App Pool? When the first request is made to the webserver? Something else? If you have the answer, could you please also provide a reference to where you got this information?

是否有这种变化在IIS 7.5的?

Does any of this change in IIS 7.5?

推荐答案

WebActivator preApplicationStart 实际上依赖于ASP.NET <一href="http://msdn.microsoft.com/en-us/library/system.web.$p$papplicationstartmethodattribute.aspx">$p$pApplicationStartMethodAttribute (见这个的链接查看网络激活是如何工作的)。

WebActivator PreApplicationStart actually relies on ASP.NET PreApplicationStartMethodAttribute (see this link to see how web activator works).

preApplicationStartMethodAttribute 工作时,<一个href="http://haacked.com/archive/2010/05/16/three-hidden-extensibility-gems-in-asp-net-4.aspx">ASP.NET运行时启动中的应用程序和code在之前app_start事件被炒鱿鱼管道初期运行。因此,要回答你的问题,触发会发生在第一次请求发送到Web服务器(这将反过来踢在应用程序启动)。

PreApplicationStartMethodAttribute works when ASP.NET runtime starts up the application and the code runs early in the pipeline even before app_start event gets fired. So to answer your question, trigger would happen when first request is made to the web server (which will in turn kicks in application start up).

请注意,触发相关的ASP.NET应用程序的开始,而不是与应用程序池。你的应用程序池可能正在运行的其它应用程序,因为(可以是非ASP.NET应用程序),但是当第一个请求来为ASP.NET应用程序,该触发器会发生(针对特定的应用程序),因为应用程序被启动。

Note that trigger is related to ASP.NET app start and not with app pool. Your app pool might be running because of some other application (can be non ASP.NET app) but when first request comes for the ASP.NET app, this trigger would happen (for particular app) because application gets started.

如果您使用的是<一href="http://weblogs.asp.net/scottgu/archive/2009/09/15/auto-start-asp-net-applications-vs-2010-and-net-4-0-series.aspx">auto-start功能,那么IIS将重新启动应用程序在你的应用程序池回收,从而 preApplicationStart 将被触发。

If you are using auto-start feature then IIS will re-start your application on your app pool recycle and thus PreApplicationStart will get triggered.

这篇关于什么时候preApplicationStartMethod居然被触发运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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