Skip to main content
A newer version of this page is available. .

Why the "Your session has expired" Error Might Occur

  • 3 minutes to read

This topic explains what causes the “Your session has expired” error and how to resolve it.

Use the chart below to determine the probable reason of the error in your application.

Deployment-servererror

The document’s state is stored on the another server

This problem occurs when you use RichEdit or Spreadsheet in a stateless environment (Clouds, Web Farms, Web Gardens) without a custom state provider.

A server loads a document to RAM and then opens the document when it receives a request. If additional requests are sent to another server that does not contain the document’s state in its RAM, the “Your session has expired” error occurs.

Solutions

Use a custom state provider

A document state provider allows you to store an opened document’s state in external storage. Web servers check out the requested documents from storage, process them, and return the latest document states. Web servers do not store server-specific states between requests.

We published two ready-to-use state providers for Redis and SQL data stores. You can find source code for these providers with sample applications is in the aspnet-office-solutions example.

Use a session affinity mode

In session affinity mode, a document’s state is stored in the RAM of a server where the document is opened. All requests to the document are redirected to this server.

Refer to solution for Azure service for an example. You can also use this approach with a different cloud platform.

More information: Scalability of ASP.NET Office Controls - Azure, Web Gardens, Farms, & Cloud Support

The CloseDocument or CloseAllDocuments method is called

If multiple users work on a document, the “Your session has expired” error can occur when a user’s actions call the CloseAllDocuments() method or if the CloseDocument(String) method is called with the wrong parameter value.

Solution

The dispose timeout for hibernated documents expired

When document hibernation is enabled (EnableHibernation), the DocumentManager hibernates inactive open documents after an idle timeout (HibernateTimeout) passed. The HibernatedDocumentsDisposeTimeout property specifies how long hibernated documents are stored on the server before disposal. An attempt to access a disposed document result in the “Your session has expired” error.

Solution

Increase the value of the HibernatedDocumentsDisposeTimeout property (24 hours by default).

Idle timeout for an application pool expired

In a stateful environment, a worker process shuts down when idle timeout for an application pool expires.

Solution

Increase the Idle Time-out value (20 minutes by default) or set the Idle Time-out to 0 (zero) to disable the timeout.

Application pool is recycled

The IIS restarts worker processes that handle requests for application pools.

Solution

Check the application pool recycle settings and increase the Regular Time Interval value.

Other reasons

If none of the described solutions help, contact our Support Center and provide a sample project, a test document, and a video that shows the steps to reproduce this message.