Handler access to Session variables

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Have a handler running on a server. Want to write and read session state variables. For a page, can just use "Session". What do I need to import and how write code for access of equivalent in a handler? Thanks.
 
Do you mean an HttpHandler? Then you can use HttpContext.Current.Session

Tom_B said:
Have a handler running on a server. Want to write and read session state
variables. For a page, can just use "Session". What do I need to import
and how write code for access of equivalent in a handler? Thanks.
 
Hello Candan,

This is part of the solution. Your handler will also need to implement IRequireSessionState or IReadOnlySessionState.

These are just marker interfaces that the framework uses to provide access to the Session object via HttpContext.Current.Session.

Let me know if you have further questions.
 
Back
Top