Dela via


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.

public ref class RouteValueAttribute abstract : Attribute, Microsoft::AspNetCore::Mvc::Routing::IRouteValueProvider
[System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Method, AllowMultiple=true, Inherited=true)]
public abstract class RouteValueAttribute : Attribute, Microsoft.AspNetCore.Mvc.Routing.IRouteValueProvider
[<System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Method, AllowMultiple=true, Inherited=true)>]
type RouteValueAttribute = class
    inherit Attribute
    interface IRouteValueProvider
Public MustInherit Class RouteValueAttribute
Inherits Attribute
Implements IRouteValueProvider
Inheritance
RouteValueAttribute
Derived
Attributes
Implements

Constructors

RouteValueAttribute(String, String)

Creates a new RouteValueAttribute.

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