RouteValueAttribute Class

Definition

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 required route data in order for the action to be selected. All other actions without a route value for the given key cannot be selected unless the route data of the request does omits a value matching the key. See IRouteValueProvider for more details and examples.

When placed on a controller, unless overridden by the action, the constraint applies to all actions defined by the controller.

C#
[System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Method, AllowMultiple=true, Inherited=true)]
public abstract class RouteValueAttribute : Attribute, Microsoft.AspNetCore.Mvc.Routing.IRouteValueProvider
Inheritance
RouteValueAttribute
Derived
Attributes
Implements

Constructors

Properties

RouteKey

The route value key.

RouteValue

The route value. If null or empty, requires the route value associated with RouteKey to be missing or null.

Applies to

Product Versions
ASP.NET Core 1.0, 1.1, 2.0, 2.1, 2.2, 3.0, 3.1, 5.0, 6.0, 7.0, 8.0, 9.0