gpt4 book ai didi

ASP.NET MVC 防伪 token 问题

转载 作者:行者123 更新时间:2023-12-03 23:25:00 26 4
gpt4 key购买 nike

我们在 ASP.NET MVC 4 站点上使用 Amazon EC2 Elastic Beanstalk,并且在用户尝试登录后收到错误消息:

The anti-forgery token could not be decrypted. If this application is hosted by a Web Farm or cluster, ensure that all machines are running the same version of ASP.NET Web Pages and that the configuration specifies explicit encryption and validation keys. AutoGenerate cannot be used in a cluster.



我们认为问题可能是由于 session 状态在 proc 中并且具有动态实例,因此我们将其移至 SQL Server,但仍然出现错误。奇怪的是,有时登录没问题,有时却出现错误。

在像 EC2 这样的动态 Web 服务器环境中,是否需要做一些特殊的事情来处理 ASP.NET MVC 的这个问题?

最佳答案

您需要在 webconfig 中包含显式设置的解密 key 和验证 key

<configuration>
<system.web>
<machineKey decryptionKey="Decryption key goes here, IsolateApps"
validationKey="Validation key goes here, IsolateApps" />
</system.web>
</configuration>

您可以查看以下文章了解详情 http://iamdotnetcrazy.blogspot.com/2013/08/how-to-solve-anti-forgery-token-could.html

关于ASP.NET MVC 防伪 token 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28210690/

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