Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Session null when performning multiple ajax calls

Tags:

c#

ajax

session

Please help as this has been driving me nuts since last week and I'm still not closer to a solution...

Environment: IIS 7.5, .Net 4.0, jQuery (latest)

I have an internal web service that I call to create a hierarchy object consisting of a number of customers and their relations. In my web service I store the hierarchy object in HttpContext.Current.Session.

Shortly there after in my javascript I loop over the customers visible to the user. For each customer I call an $.ajax function that calls another procedure in my web service. In the C# code I read my hierarchy object from HttpContext.Current.Session and using linq reads the data for the current customer.

My problem is that HttpContext.Current.Session["hierarchy"] returns null for some customers. It's not the same customers each time even though I'm calling the exact same url.

I have tried reading the hierarchy from HttpContext.Current.Session immediately after writing it just to verify that everything in my hierarchy object is actually written to HttpContext.Current.Session.

I have tried logging HttpContext.Current.Session.SessionId to verify that the session is the same and everything adds up.

I have tried with and without EnableSessionState in my Default.apsx

Thanks in advance to anyone who can guide me in the right direction...

./CJ

like image 798
CJe Avatar asked Mar 24 '26 09:03

CJe


1 Answers

Is your web service made of WCF? If so, there is no session at all unless asp.net compatibility mode is enabled.

like image 90
xing Avatar answered Mar 26 '26 23:03

xing