RequireHttpsAttribute 類別

定義

確認透過 HTTPS 接收要求的授權篩選器。

public ref class RequireHttpsAttribute : Attribute, Microsoft::AspNetCore::Mvc::Filters::IAuthorizationFilter, Microsoft::AspNetCore::Mvc::Filters::IOrderedFilter
[System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Method, AllowMultiple=false, Inherited=true)]
public class RequireHttpsAttribute : Attribute, Microsoft.AspNetCore.Mvc.Filters.IAuthorizationFilter, Microsoft.AspNetCore.Mvc.Filters.IOrderedFilter
[<System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Method, AllowMultiple=false, Inherited=true)>]
type RequireHttpsAttribute = class
    inherit Attribute
    interface IAuthorizationFilter
    interface IFilterMetadata
    interface IOrderedFilter
Public Class RequireHttpsAttribute
Inherits Attribute
Implements IAuthorizationFilter, IOrderedFilter
繼承
RequireHttpsAttribute
屬性
實作

建構函式

RequireHttpsAttribute()

確認透過 HTTPS 接收要求的授權篩選器。

屬性

Order

取得決定篩選準則執行順序的順序值。 篩選會以屬性的 Order 遞增數值執行。

Permanent

指定是否應該使用永久重新導向 301 Moved Permanently ,而不是暫時重新導向 302 Found

方法

HandleNonHttpsRequest(AuthorizationFilterContext)

如果未透過 HTTPS 接收要求,請從 OnAuthorization(AuthorizationFilterContext) 呼叫。 Result預期不會 null 在此方法傳回之後。

OnAuthorization(AuthorizationFilterContext)

在篩選管線中提早呼叫,以確認要求已獲得授權。 確認已透過 HTTPS 接收要求。 對 HTTPS 要求不採取任何動作。 否則,如果是 GET 要求,請將 設定 Result 為結果,以將用戶端重新導向至要求 URI 的 HTTPS 版本。 否則,將 設定 Result 為結果,將狀態碼設定為 403 (禁止) 。

適用於