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.
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.