本文介绍了当会话状态在ASP.NET管道初始化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有对的AuthorizeRequest事件处理程序的IHttpModule的。我想访问Session对象,但它尚未初始化。哪个事件我要订阅,以便尽早在管道可用会话对象?

I have an IHTTPModule with an event handler for AuthorizeRequest. I would like to access the Session object but it is not yet initialized. Which event should I subscribe to in order to have the session object available as early as possible in the pipeline?

推荐答案

您needd HttpApplication.PostAcquireRequestState事件 -
http://msdn.microsoft.com/en-us/library/system.web.httpapplication.postacquirerequeststate.aspx.也有一个HttpApplication.AcquireRequestState事件。不要忘记检查,如果您的处理程序实现IRequiresSessionState或IReadOnlySessionState,否则会抛出异常。

You needd HttpApplication.PostAcquireRequestState event -http://msdn.microsoft.com/en-us/library/system.web.httpapplication.postacquirerequeststate.aspx. Also there is a HttpApplication.AcquireRequestState event. Don't forget to check if your handler implements IRequiresSessionState or IReadOnlySessionState, otherwise it will throw an exception.

这篇关于当会话状态在ASP.NET管道初始化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-23 16:46