Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

My app sometimes calls Server.Transfer in the Application_OnPostAuthenticateRequest event of the global.asax to act as kind of url rewite. When this happens and I need to access Session I get an HttpException: "Session state can only be used when enableSessionState is set to true..." I am assuming this is happening because of the event I am calling Server.Transfer. Is that why I am getting the exception? When should I do the transfer?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
398 views
Welcome To Ask or Share your Answers For Others

1 Answer

The PostAuthenticateRequest occurs before the AcquireRequestState and the session state should only be available after this event is raised, so if you need to access session state for the request you need to wait for that event.

See this page as a reference.

  1. ...
  2. Raise the PostAuthenticateRequest event.
  3. ...
  4. Raise the AcquireRequestState event.
  5. ...

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...