Table of Contents

Class RequireHttpsAttribute

Namespace
System.Web.Mvc
Assembly
System.Web.Mvc.dll

Represents an attribute that forces an unsecured HTTP request to be re-sent over HTTPS.

[AttributeUsage(AttributeTargets.Class|AttributeTargets.Method, Inherited = true, AllowMultiple = false)]
public class RequireHttpsAttribute : FilterAttribute, IMvcFilter, IAuthorizationFilter
Inheritance
RequireHttpsAttribute
Implements
Inherited Members

Constructors

RequireHttpsAttribute()

Initializes a new instance of the RequireHttpsAttribute class.

public RequireHttpsAttribute()

RequireHttpsAttribute(bool)

public RequireHttpsAttribute(bool permanent)

Parameters

permanent bool

Properties

Permanent

public bool Permanent { get; }

Property Value

bool

Methods

HandleNonHttpsRequest(AuthorizationContext)

Handles unsecured HTTP requests that are sent to the action method.

protected virtual void HandleNonHttpsRequest(AuthorizationContext filterContext)

Parameters

filterContext AuthorizationContext

An object that encapsulates information that is required in order to use the RequireHttpsAttribute attribute.

Exceptions

InvalidOperationException

The HTTP request contains an invalid transfer method override. All GET requests are considered invalid.

OnAuthorization(AuthorizationContext)

Determines whether a request is secured (HTTPS) and, if it is not, calls the HandleNonHttpsRequest(AuthorizationContext) method.

public virtual void OnAuthorization(AuthorizationContext filterContext)

Parameters

filterContext AuthorizationContext

An object that encapsulates information that is required in order to use the RequireHttpsAttribute attribute.

Exceptions

ArgumentNullException

The filterContext parameter is null.