Azure Redis缓存的会话状态不适用于多个实例 [英] Session State with Azure Redis Cache not working on multiple instances

查看:51
本文介绍了Azure Redis缓存的会话状态不适用于多个实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Azure Redis缓存存储用户会话以在多个实例上共享它.但这不起作用...我已经登录,并且负载平衡器将我的请求定向到另一个Web服务器后,我就在另一个服务器上注销了.这是我当前的web.config:

I'm using Azure Redis Cache to store the session of the users to share it over multiple instances. But this not working... i'm logged in and as soon as the load balancer directs my request to the other Webserver i'm loggout out on the other server. This is my current web.config:

<sessionState mode="Custom" customProvider="RedisSessionStateStore">
  <providers>
    <add name="RedisSessionStateStore" type="Microsoft.Web.Redis.RedisSessionStateProvider" host="HOSTNAME.redis.cache.windows.net" accessKey="ACCESSKEY" ssl="true" />
  </providers>
</sessionState>

在门户中,我可以看到该应用程序将数据写入高速缓存,以便连接正常工作.如果有帮助,我的身份验证部分将如下所示:

In the portal i can see, that the application writes data into the cache so the connection is working. If it is any help my authentication Part looks like this:

<authentication mode="Forms">
  <forms loginUrl="Welcome.aspx" defaultUrl="default.aspx" cookieless="UseCookies" timeout="60000" />
</authentication>

我还需要做些其他事才能在多个Web服务器上运行它吗?在这些教程中,我仅发现上述有关sessionState的配置.

Is there anything else i need to do to get this running on multiple webservers? In the tutorials i found only the configuration above regarding the sessionState.

感谢您的帮助!

Br,代谢

推荐答案

我发现了问题.我在服务器上使用了不同的machineKeys,因此无法在其他Web服务器上对身份验证cookie进行解码.

i found the problem. i had different machineKeys on the servers so the authentication cookie could not be decoded on the other Webserver.

这篇关于Azure Redis缓存的会话状态不适用于多个实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆