RequireAntiforgeryTokenAttribute 類別
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
一個可用來指示是否必須驗證防偽造令牌的屬性。
[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) 在你的處理器中進行。
建構函式
| 名稱 | Description |
|---|---|
| RequireAntiforgeryTokenAttribute(Boolean) |
一個可用來指示是否必須驗證防偽造令牌的屬性。 |
屬性
| 名稱 | Description |
|---|---|
| RequiresValidation |
取得或設定一個值,指示是否應驗證反偽造令牌。 |