HttpContext.Current.Session is null in Ashx file

前端 未结 1 491
执念已碎
执念已碎 2020-11-29 03:09

I saw some questions (Here and Here) but they do not answer my question. I am trying to call Ajax using \"ajax.ashx\" file, and in function to access Session. For some reas

相关标签:
1条回答
  • 2020-11-29 03:30

    You must add on your handler the IRequiresSessionState on the declaration of it as:

    public class YourHandleName : IHttpHandler, IRequiresSessionState 
    {
    ...
    

    by default the handlers are not connected with the session to keep them minimum, by adding the IRequiresSessionState you attach them with the session.

    0 讨论(0)
提交回复
热议问题