全局 asax application_start 应用程序 begin_request 方法?
我有个问题。 在 IIS 7.0 中从经典管道模式迁移到集成管道模式时,我们遇到了以下问题:
“/”应用程序中的服务器错误。
请求在此上下文中不可用...
我们很快就找到了此问题的解决方案
mvolo.com/blogs/serverside/archive/2007/11/10/Integrated-mode-Request-is-not-available-in-this-context-in-Application_5F00_Start.aspx
,在 global.asax 中,我必须将 application_start 事件转发到 Application_BeginRequest 事件。
void Application_Start(object sender, EventArgs e) { // sender has type 'System.Web.HttpApplicationFactory' }
Application_BeginRequest(Object source, EventArgs e) | {
// sender has type 'System.Web.HttpApplication' }
或者另一个解决方案是, Application_Start 事件可以晚于 Application_BeginRequest 启动。
有什么建议 ? 我没有选择“经典模式”之类的选择
I have a problem. While migrating from classic pipeline mode to integrated pipeline mode at IIS 7.0 we encounter the problem :
Server Error in '/' Application.
Request is not available in this context...
We found solution for this problem at
mvolo.com/blogs/serverside/archive/2007/11/10/Integrated-mode-Request-is-not-available-in-this-context-in-Application_5F00_Start.aspx
As solution shortly ,in global.asax I must forward the application_start event to Application_BeginRequest event.
void Application_Start(object sender, EventArgs e) { // sender has type 'System.Web.HttpApplicationFactory' }
Application_BeginRequest(Object source, EventArgs e) | {
// sender has type 'System.Web.HttpApplication' }
Or another solution is, Application_Start event can start later then Application_BeginRequest .
any suggestions ?
I have no option like choosing "classic mode "
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将代码移至
Application_BeginRequest
或Session_Start
。 无论如何,您都不应该在Application_Start
中使用Request
对象。Request
对象包含特定于一页请求的信息。 在Application_Start
事件中使用此信息执行任何操作实际上没有任何意义。Move the code to
Application_BeginRequest
orSession_Start
. You shouldn't use theRequest
object inApplication_Start
anyway.The
Request
object contains information that is specific for one page request. It doesn't really make any sense to do anything with this information in theApplication_Start
event.因此,将应用程序池模式更改为经典。
So, change you app pool mode to classic.