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?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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.