Posted By

fengelz on 06/18/10


Tagged

handler sessionstate ashx


Versions (?)

Maintain sessionstate in generic ashx handler


 / Published in: C#
 

If you are working with an ashx handler and need to access your session, this is one way it can be done.

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5.  
  6. namespace MyGenericHandler
  7. {
  8. /// <summary>
  9. /// Summary description for $codebehindclassname$
  10. /// </summary>
  11.  
  12. public class Handler : IHttpHandler,
  13. System.Web.SessionState.IRequiresSessionState
  14. {
  15. public void ProcessRequest(HttpContext context)
  16. {
  17. context.Session.Add("myVal",
  18. context.Request["myVal"]);
  19. }
  20.  
  21. public bool IsReusable
  22. {
  23. get
  24. {
  25. return false;
  26. }
  27. }
  28. }
  29. }

Report this snippet  

You need to login to post a comment.