'The document is expired' issue when running several reports simultaneously

Silverlight Viewer for Reporting Services uses an ASP session to store data associated with the report displayed on the server side. When using the latest versions of IIS and loading several reports in quick succession 'The document is expired' error may occur. The most obvious cause of the problem is that latest versions of IIS do not start a session unless the code of the application explicitly works with it.

To get deeper into specific details, the scenario looks as follows. The session starts on the server side and its ID is saved to a web browser cookie on response. When the rendering of several reports is started simultaneously, the report viewers switch to asynchronous operation mode and simultaneously call a method that saves data to session. Since each request does not have any initial session, the server starts the session, saves data to it and returns session cookie to a client side. Eventually, web browser receives several commands with server responses to set several different cookies and one by one it overwrites the session cookie value. As a result, only one session usually survives (the one that was received last). When a user tries to access the report viewer that lost its session, the server attempts to restore a report context form another session, but it fails to find it and returns a 'The document is expired' or 'Report is out of cache' message in this case.

In order to avoid this problem, check to make sure that session has already been started by the moment when the reports rendering is initiated. The easiest way to fix this problem is to add the global.asax file to your server side project and to define a Session_Start handler. Adding this handler will force IIS to create a session on the very first request to the server. Also, check to make sure that Visual Studio does not remove it while optimizing the code if the handler is left empty. Another approach for initiating a session is to make a server call before the rendering is started. This server call is meant to save some data to session on the server side and only after a request to this call is received the rendering process should be started.

Add Feedback