RouteValueAttribute Class

<p> An attribute which specifies a required route value for an action or controller. </p> <p> 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.AspNetCore.Mvc.Routing.IRouteValueProvider for the expectations that must be satisfied by the route data. </p> <p> When placed on a controller, unless overridden by the action, the constraint applies to all actions defined by the controller. </p>

Namespace
Microsoft.AspNetCore.Mvc.Routing
Assemblies
  • Microsoft.AspNetCore.Mvc.Core

Syntax

[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
public abstract class RouteValueAttribute : Attribute, _Attribute, IRouteValueProvider
class Microsoft.AspNetCore.Mvc.Routing.RouteValueAttribute

Constructors

RouteValueAttribute(System.String, System.String)

Creates a new Microsoft.AspNetCore.Mvc.Routing.RouteValueAttribute.

Arguments:
  • routeKey (System.String) – The route value key.
  • routeValue (System.String) – The expected route value.
protected RouteValueAttribute(string routeKey, string routeValue)

Properties

Microsoft.AspNetCore.Mvc.Routing.RouteValueAttribute.RouteKey
Return type:System.String
public string RouteKey { get; }
Microsoft.AspNetCore.Mvc.Routing.RouteValueAttribute.RouteValue
Return type:System.String
public string RouteValue { get; }