Unable to use Session State Server


Issue

ASP.NET site running under .NET 2.0 has the following setting in web.config:

<sessionState mode="StateServer" stateNetworkTimeout="10" 
cookieless="false" timeout="30"/>

When the application attempts to use the session cache, the following exception is thrown:

HttpException (0x80004005): Unable to use session state server because this version of ASP.NET requires session state server version 2.0 or above.

This exception occurs the very first time the session cache is used after the application is published to the server, after IIS is restarted, or after the application pool recycles.  Subsequent uses of the session cache after the first exception is thrown do not result in an error.  The session cache continues to work properly until the next application re-publish, IIS restart, or application pool recycle.

Cause

ASP.NET State server uses HTTP Requests to manage the session state requests.  When sending the response back to the Web application the state server should be including a header":

X-ASPNet-Version: 2.xxxx header

The Session State Server reads this header, and checks to see if the major version is < 2, if so it will throw the exception.

In one case we had with a customer, the header is never being returned.  It is never being returned because in the <httpRuntime> Configuration section they had:

enableVersionHeader = “false”.

Now, why did this only happen for the first request?  Well, in the very first request to our state server, we check to see if we already know the state server version by comparing to -1. If not, we check the version during the response.  While we are checking the version upon response we set the version to 0 which prevents us from checking the version ever again, since it isn’t -1.

kick it on DotNetKicks.com

Comments (5)

  1. Boris says:

    Good article, however didn’t solve the issue. I’ve set enableVersionHeader  to "true" and confirmed with fiddler that response contains version headers, but still seeing the issue

  2. Mick Byrne says:

    This is a really nice clear article, but does not explain how to solve the problem. I would love to get an answer as to how to prevent this from happening…

  3. tomchris says:

    The solution given here is to look at the HTTP headers and see if X-ASPNet-Version is there.  If not, check that setting.  As that header missing will cause the problem.

  4. karta says:

    that is because the ASP DOT NET state service has not been started, just start it , the error would be fixed.