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 (禁止) 的结果。

适用于