gpt4 book ai didi

asp.net-mvc - 跨多个应用服务计划覆盖 Microsoft Azure 应用服务上的 MachineKey

转载 作者:行者123 更新时间:2023-12-02 05:51:25 25 4
gpt4 key购买 nike

我正在尝试在 ASP.Net MVC 应用程序的 Web.Config 中设置机器 key ,但听起来像 Azure automatically provision unique machine keys for each web app并覆盖我的 Web.Config 中的内容。

我想这样做的原因是因为我有一个应用程序服务用作身份验证应用程序。这就是用户登录的地方。我还有很多其他应用程序将使用第一个应用程序提供的 token 。这样做将在一个唯一的位置对用户进行身份验证,并且用户将能够浏览仅经过一次身份验证的门户中的某些模块。它在本地主机或 IIS 中运行得很好,但在 Azure 托管应用服务上,即使我在 Application_Start 上重置了机器 key 配置部分,机器 key 似乎也无法正确读取。

我尝试了描述的解决方案 Here ,但正如@gorillapower所说

Seems this isnt working for us. We are using .NET 4.6.1 and using OWIN startup with app.UseCookieAuthentication() and using a Redis cache session provider. I implemented the above, but the user keeps getting logged out after a slot swap. Any ideas?

似乎当您在应用服务计划 (ASP) 的多个实例上运行 ASP.NET 应用程序时 you do not need to worry about machineKeys as the App Service Platform will use the same one across all your instances因此不需要对您的应用程序进行任何更改。

但就我而言,我们的应用程序都位于不同的应用程序服务计划中。所以这个解决方案不适用。

关于这个问题有什么线索吗?谢谢

最佳答案

生成机器 key 并添加到web.config文件中

它将适用于 IIS 或 Azure Web App 服务中的 Web Farm/负载均衡器。注意:仅当您使用 IAppBuilder->UseCookieAuthentication-> CookieAuthenticationOptions

时才有效
<system.web>
<authentication mode="None" />
<machineKey validation="HMACSHA256" decryption="AES" validationKey="D6883865C0490AFA4907A046E838DD2C7B13B636694B552630C13770701B944A" decryptionKey="2C3C48562E6FE018E71B69BDB27D06048A573C094A962AA9A1547C3D874C63B0" />

关于asp.net-mvc - 跨多个应用服务计划覆盖 Microsoft Azure 应用服务上的 MachineKey,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52260112/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com