ASP.NET session has expired or could not be found -> Because the Session.SessionID changes (Reporting Services)

user1239198 picture user1239198 · Feb 29, 2012 · Viewed 53.3k times · Source

1.-I'm using reporting services and sometimes I get this error ASP.NET session has expired or could not be found when I try to load a report.

2.-I realized that I get this error when the Session.SessionID property changes even though the user is the same. If it does not change, the report is loaded. I mean, if I refresh the report a number of times, whenever the Session.SessionID is the same than the last one, the report is loaded.

3.-Microsoft Documentation says:

When using cookie-based session state, ASP.NET does not allocate storage for session data until the Session object is used. As a result, a new session ID is generated for each page request until the session object is accessed. If your application requires a static session ID for the entire session, you can either implement the Session_Start method in the application's Global.asax file and store data in the Session object to fix the session ID, or you can use code in another part of your application to explicitly store data in the Session object.

If your application uses cookieless session state, the session ID is generated on the first page view and is maintained for the entire session.

The point is that I can not use a cookieless session state because I need cookies.

What could I do to avoid this error? Or What could I do to avoid the Session.SessionID to change on every request?

Answer

Aleksandar Vucetic picture Aleksandar Vucetic · Feb 29, 2012

You are probably storing your session InProcess. Try changing it to session state server. You can find more details here.