LengthRouteConstraint Class¶
Constrains a route parameter to be a string of a given length or within a given range of lengths.
- Namespace
Microsoft.AspNetCore.Routing.Constraints
- Assemblies
- Microsoft.AspNetCore.Routing
Syntax¶
public class LengthRouteConstraint : IRouteConstraint
-
class
Microsoft.AspNetCore.Routing.Constraints.
LengthRouteConstraint
Constructors¶
-
LengthRouteConstraint
(System.Int32)¶ Initializes a new instance of the
Microsoft.AspNetCore.Routing.Constraints.LengthRouteConstraint
class that constrains a route parameter to be a string of a given length.Arguments: length (System.Int32) – The length of the route parameter. public LengthRouteConstraint(int length)
-
LengthRouteConstraint
(System.Int32, System.Int32) Initializes a new instance of the
Microsoft.AspNetCore.Routing.Constraints.LengthRouteConstraint
class that constrains a route parameter to be a string of a given length.Arguments: - minLength (System.Int32) – The minimum length allowed for the route parameter.
- maxLength (System.Int32) – The maximum length allowed for the route parameter.
public LengthRouteConstraint(int minLength, int maxLength)
-
Methods¶
-
Match
(Microsoft.AspNetCore.Http.HttpContext, Microsoft.AspNetCore.Routing.IRouter, System.String, Microsoft.AspNetCore.Routing.RouteValueDictionary, Microsoft.AspNetCore.Routing.RouteDirection)¶ Return type: System.Boolean public bool Match(HttpContext httpContext, IRouter route, string routeKey, RouteValueDictionary values, RouteDirection routeDirection)
-
Properties¶
-
Microsoft.AspNetCore.Routing.Constraints.LengthRouteConstraint.
MaxLength
¶ Gets the maximum length allowed for the route parameter.
Return type: System.Int32 public int MaxLength { get; }
-
Microsoft.AspNetCore.Routing.Constraints.LengthRouteConstraint.
MinLength
¶ Gets the minimum length allowed for the route parameter.
Return type: System.Int32 public int MinLength { get; }
-