Table of Contents

Class ControllerDescriptor

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

Encapsulates information that describes a controller, such as its name, type, and actions.

public abstract class ControllerDescriptor : ICustomAttributeProvider
Inheritance
ControllerDescriptor
Implements
Derived
Inherited Members

Constructors

ControllerDescriptor()

Initializes a new instance of the ControllerDescriptor class.

protected ControllerDescriptor()

Properties

ControllerName

Gets the name of the controller.

public virtual string ControllerName { get; }

Property Value

string

The name of the controller.

ControllerType

Gets the type of the controller.

public abstract Type ControllerType { get; }

Property Value

Type

The type of the controller.

UniqueId

When implemented in a derived class, gets the unique ID for the controller descriptor using lazy initialization.

public virtual string UniqueId { get; }

Property Value

string

The unique ID.

Methods

FindAction(ControllerContext, string)

Finds an action method by using the specified name and controller context.

public abstract ActionDescriptor FindAction(ControllerContext controllerContext, string actionName)

Parameters

controllerContext ControllerContext

The controller context.

actionName string

The name of the action.

Returns

ActionDescriptor

The information about the action method.

GetCanonicalActions()

Retrieves a list of action-method descriptors in the controller.

public abstract ActionDescriptor[] GetCanonicalActions()

Returns

ActionDescriptor[]

A list of action-method descriptors in the controller.

GetCustomAttributes(bool)

Retrieves custom attributes that are defined for this member, excluding named attributes.

public virtual object[] GetCustomAttributes(bool inherit)

Parameters

inherit bool

true to look up the hierarchy chain for the inherited custom attribute; otherwise, false.

Returns

object[]

An array of custom attributes, or an empty array if no custom attributes exist.

Exceptions

TypeLoadException

The custom attribute type cannot be loaded.

AmbiguousMatchException

There is more than one attribute of type attributeType defined for this member.

GetCustomAttributes(Type, bool)

Retrieves custom attributes of a specified type that are defined for this member, excluding named attributes.

public virtual object[] GetCustomAttributes(Type attributeType, bool inherit)

Parameters

attributeType Type

The type of the custom attributes.

inherit bool

true to look up the hierarchy chain for the inherited custom attribute; otherwise, false.

Returns

object[]

An array of custom attributes, or an empty array if no custom attributes exist.

Exceptions

TypeLoadException

The custom attribute type cannot be loaded.

AmbiguousMatchException

There is more than one attribute of type attributeType defined for this member.

ArgumentNullException

The attributeType parameter is null (Nothing in Visual Basic).

GetFilterAttributes(bool)

Gets the filter attributes.

public virtual IEnumerable<FilterAttribute> GetFilterAttributes(bool useCache)

Parameters

useCache bool

true if the cache should be used; otherwise, false.

Returns

IEnumerable<FilterAttribute>

The filter attributes.

IsDefined(Type, bool)

Retrieves a value that indicates whether one or more instance of the specified custom attribute are defined for this member.

public virtual bool IsDefined(Type attributeType, bool inherit)

Parameters

attributeType Type

The type of the custom attribute.

inherit bool

true to look up the hierarchy chain for the inherited custom attribute; otherwise, false.

Returns

bool

true if the attributeType is defined for this member; otherwise, false.

Exceptions

ArgumentNullException

The attributeType parameter is null (Nothing in Visual Basic).