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

Popular posts from this blog

jasper reports - Fixed header in Excel using JasperReports -

media player - Android: mediaplayer went away with unhandled events -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -