Table of Contents

Class AuthorizeAttribute

Namespace
System.Web.Http
Assembly
System.Web.Http.dll

Specifies the authorization filter that verifies the request's IPrincipal.

[AttributeUsage(AttributeTargets.Class|AttributeTargets.Method, Inherited = true, AllowMultiple = true)]
public class AuthorizeAttribute : AuthorizationFilterAttribute, IAuthorizationFilter, IFilter
Inheritance
AuthorizeAttribute
Implements
Inherited Members

Constructors

AuthorizeAttribute()

Initializes a new instance of the AuthorizeAttribute class.

public AuthorizeAttribute()

Properties

Roles

Gets or sets the authorized roles.

public string Roles { get; set; }

Property Value

string

The roles string.

TypeId

Gets a unique identifier for this attribute.

public override object TypeId { get; }

Property Value

object

A unique identifier for this attribute.

Users

Gets or sets the authorized users.

public string Users { get; set; }

Property Value

string

The users string.

Methods

HandleUnauthorizedRequest(HttpActionContext)

Processes requests that fail authorization.

protected virtual void HandleUnauthorizedRequest(HttpActionContext actionContext)

Parameters

actionContext HttpActionContext

The context.

IsAuthorized(HttpActionContext)

Indicates whether the specified control is authorized.

protected virtual bool IsAuthorized(HttpActionContext actionContext)

Parameters

actionContext HttpActionContext

The context.

Returns

bool

true if the control is authorized; otherwise, false.

OnAuthorization(HttpActionContext)

Calls when an action is being authorized.

public override void OnAuthorization(HttpActionContext actionContext)

Parameters

actionContext HttpActionContext

The context.

Exceptions

ArgumentNullException

The context parameter is null.