HttpContext.Current.Session is null in Ashx file

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 reason, the value of the Session object itself is null.

Use example:

Session = HttpContext.Current.Session // This is null


public virtual void ProcessRequest(HttpContext context)
    System.Web.SessionState.HttpSessionState Session = context.Session; 
    // This is null

In the Web.config:

<sessionState timeout="1800"></sessionState>


Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

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.

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x