假设上下文处理程序是IRequiresSessionState或IReadOnlySessionState,可以访问Session的第一个global.asax事件是什么?

Mik*_*ike 3 c# asp.net

我的应用程序调用,有时Server.TransferApplication_OnPostAuthenticateRequest在Global.asax作为一种URL rewite的事件.当发生这种情况并且我需要访问时,Session我得到一个HttpException:"只有当enableSessionState设置为true时才能使用会话状态......"我假设这是因为我正在调用的事件而发生这种情况Server.Transfer.这就是我得到例外的原因吗?我什么时候应该转移?

Joã*_*elo 8

PostAuthenticateRequest之前的发生AcquireRequestState和会话状态应该只可引发此事件之后,因此,如果您需要访问会话状态,你需要等待该事件的请求.

请参阅此页面作为参考.

  1. ...
  2. 提升PostAuthenticateRequest事件.
  3. ...
  4. 提升AcquireRequestState事件.
  5. ...