gpt4 book ai didi

asp.net-mvc - 如何禁用 ASP.NET MVC Core 2 中的防伪 token 检查

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

我试图避免“AntiForgery”检查,因为从第 3 方服务器托管时它总是失败。我正在使用 ASP.NET Core 2.0 MVC 应用程序。

我在 ConfigureServices 函数中添加了此选项:

services
.AddMvc()
.AddRazorPagesOptions( options =>
{
options.Conventions.AuthorizeFolder("/Account/Manage");
options.Conventions.AuthorizePage("/Account/Logout");
options.Conventions.ConfigureFilter(new IgnoreAntiforgeryTokenAttribute());
} );

但我仍然遇到这个异常。

System.InvalidOperationException: The antiforgery token could not be decrypted.
System.Security.Cryptography.CryptographicException: The key {6fb328e7-4808-4b5d-b7dc-870d126e5ca4} was not found in the key ring.

我错过了什么吗?

最佳答案

IgnoreAntiforgeryToken 属性(订单必须 > 1000)添加到 razor 页面模型:

例如:

namespace CWACpch.Pages
{
[IgnoreAntiforgeryToken(Order = 2000)]
public class CreateOrderModel : PageModel
{

关于asp.net-mvc - 如何禁用 ASP.NET MVC Core 2 中的防伪 token 检查,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50442256/

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