RouteConstraintAttribute Class¶
Summary¶
An attribute which specifies a required route value for an action or controller.
When placed on an action, the route data of a request must match the expectations of the route constraint in order for the action to be selected. See [Microsoft.AspNet.Mvc.RouteConstraintAttribute.RouteKeyHandling](Microsoft.AspNet.Mvc.RouteConstraintAttribute.yml) for the expectations that must be satisfied by the route data.
When placed on a controller, unless overridden by the action, the constraint applies to all actions defined by the controller.
Inheritance Hierarchy¶
System.Object
System.Attribute
Microsoft.AspNet.Mvc.RouteConstraintAttribute
Syntax¶
public abstract class RouteConstraintAttribute : Attribute, _Attribute, IRouteConstraintProvider
Constructors¶
-
RouteConstraintAttribute
(System.String, Microsoft.AspNet.Mvc.RouteKeyHandling)¶ Creates a new [Microsoft.AspNet.Mvc.RouteConstraintAttribute](Microsoft.AspNet.Mvc.RouteConstraintAttribute.yml).
Arguments: - routeKey (System.String) – The route value key.
- keyHandling (Microsoft.AspNet.Mvc.RouteKeyHandling) – The [Microsoft.AspNet.Mvc.RouteConstraintAttribute.RouteKeyHandling](Microsoft.AspNet.Mvc.RouteConstraintAttribute.yml) value. Must be [Microsoft.AspNet.Mvc.RouteKeyHandling.CatchAll]() or [Microsoft.AspNet.Mvc.RouteKeyHandling.DenyKey]().
protected RouteConstraintAttribute(string routeKey, RouteKeyHandling keyHandling)
-
RouteConstraintAttribute
(System.String, System.String, System.Boolean) Creates a new [Microsoft.AspNet.Mvc.RouteConstraintAttribute](Microsoft.AspNet.Mvc.RouteConstraintAttribute.yml) with [Microsoft.AspNet.Mvc.RouteConstraintAttribute.RouteKeyHandling](Microsoft.AspNet.Mvc.RouteConstraintAttribute.yml) set to [Microsoft.AspNet.Mvc.RouteKeyHandling.RequireKey]().
Arguments: - routeKey (System.String) – The route value key.
- routeValue (System.String) – The expected route value.
- blockNonAttributedActions (System.Boolean) – Set to true to negate this constraint on all actions that do not define a behavior for this route key.
protected RouteConstraintAttribute(string routeKey, string routeValue, bool blockNonAttributedActions)
-
Properties¶
-
BlockNonAttributedActions
()¶ Return type: System.Boolean public bool BlockNonAttributedActions { get; }
-
RouteKey
()¶ Return type: System.String public string RouteKey { get; }
-
RouteKeyHandling
()¶ Return type: Microsoft.AspNet.Mvc.RouteKeyHandling public RouteKeyHandling RouteKeyHandling { get; }
-
RouteValue
()¶ Return type: System.String public string RouteValue { get; }
-