c# - Session in generic handler? -
i have following simple handler (removed code vissibilty sakes, below still fails)
<%@ webhandler language="c#" class="downloadhandler" %> using system; using system.web; public class downloadhandler : ihttphandler { public void processrequest(httpcontext context) { if (context.session["t1"] != "true") { } } public bool isreusable { { return false; } } }
the line if (context.session["t1"] != "true")
failing "object reference not set instance of object." , dont quite why is?
that's because http handler in order access session
need explicitly implement irequiressessionstate
interface.
keep in mind if there implicit locking on session object , won't able have multiple handlers in same session state processed simultaneously.
there ireadonlysessionstate
interface read-only session state access.
Comments
Post a Comment