语言

RequireAntiforgeryTokenAttribute 类

定义

可用于指示是否必须验证反forgery 令牌的属性。

[System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Method)]
public class RequireAntiforgeryTokenAttribute : Attribute, Microsoft.AspNetCore.Antiforgery.IAntiforgeryMetadata
[<System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Method)>]
type RequireAntiforgeryTokenAttribute = class
    inherit Attribute
    interface IAntiforgeryMetadata
Public Class RequireAntiforgeryTokenAttribute
Inherits Attribute
Implements IAntiforgeryMetadata
继承
RequireAntiforgeryTokenAttribute
属性
实现

注解

验证仅 UseAntiforgery(IApplicationBuilder) 应用于 HTTP POST、PUT 和 PATCH 请求。 即使应用此属性,中间件也会跳过使用其他 HTTP 方法的终结点。

如果需要验证其他 HTTP 方法,请解析IAntiforgery和调用ValidateRequestAsync(HttpContext)IsRequestValidAsync(HttpContext)或处理程序。

构造函数

名称 说明
RequireAntiforgeryTokenAttribute(Boolean)

可用于指示是否必须验证反forgery 令牌的属性。

属性

名称 说明
RequiresValidation

获取或设置一个值,该值指示是否应验证反forgery 令牌。

适用于