RequireAntiforgeryTokenAttribute Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
An attribute that can be used to indicate whether the antiforgery token must be validated.
[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
- Inheritance
-
RequireAntiforgeryTokenAttribute
- Attributes
- Implements
Remarks
Validation performed by UseAntiforgery(IApplicationBuilder) only applies to HTTP POST, PUT, and PATCH requests. Endpoints using other HTTP methods are skipped by the middleware even when this attribute is applied.
If you need validation for other HTTP methods, resolve IAntiforgery and call ValidateRequestAsync(HttpContext) or IsRequestValidAsync(HttpContext) in your handler.
Constructors
| Name | Description |
|---|---|
| RequireAntiforgeryTokenAttribute(Boolean) |
An attribute that can be used to indicate whether the antiforgery token must be validated. |
Properties
| Name | Description |
|---|---|
| RequiresValidation |
Gets or sets a value indicating whether the antiforgery token should be validated. |