PreApplicationStartMethod 何时真正被触发运行? [英] When does PreApplicationStartMethod actually get triggered to run?

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

问题描述

当使用 WebActivator PreApplicationStart 方法时,究竟是什么触发了绑定到 this 的方法运行?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 PreApplicationStartMethodAttribute(参见 链接以了解 Web 激活器的工作原理).

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

PreApplicationStartMethodAttributeASP.NET 运行时启动应用程序,并且代码在管道中的早期运行,甚至在 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.

如果您使用 自动启动 功能,然后 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天全站免登陆