Maintain sessionstate in generic ashx handler


/ Published in: C#
Save to your folder(s)

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


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.