0
votes

I'm using the following configuration on a cloud services instance in Azure for ASP.NET sessionstate in the Web.Config:

<sessionState mode="Custom" customProvider="DistributedCacheSessionStateStoreProvider">
  <providers>
    <add name="DistributedCacheSessionStateStoreProvider" type="Microsoft.Web.DistributedCache.DistributedCacheSessionStateStoreProvider, Microsoft.Web.DistributedCache" cacheName="default" useBlobMode="true" dataCacheClientName="default" />
  </providers>
</sessionState>

And the datacacheclient's configuration:

  <dataCacheClients>
    <dataCacheClient name="default" isCompressionEnabled="false">
      <autoDiscover isEnabled="true" identifier="InternetWebRole" />
      <localCache isEnabled="true" sync="TimeoutBased" objectCount="100000" ttlValue="300" />
    </dataCacheClient>
  </dataCacheClients>

When I create a new deployment to Cloud Services, the process was succesfully executed. But when I login on the website, the session only lasts for 1 or 2 requests. Clicking to another page redirects me back to the login-page. The authentication of my profile is succesful, but the session is expired almost immediately. I'm using forms-authentication using the normal ASP.NET membership provider:

<authentication mode="Forms">
  <forms loginUrl="/Login" timeout="120" />
</authentication>

Strange thing is that 3 or 4 hours later, the problem solves itself. I can login again and it keeps my session for two hours straight. I've kept the instance running now for the weekend and still everyting is working fine. But as soon as I delete the deployment and create a new one the problem starts all over again. Is there anyone that recognize this issue with the same sessionstate provider?

1

1 Answers

0
votes

I've solved the issue by adding a machine key to the web.config, which is the same for all cloud services instaces.