Route Constraints

The following table lists the options for constraining route parameters by data type and range:

Constraint Description Example
alpha Matches uppercase or lowercase Latin alphabet characters (a-z, A-Z) {title:alpha}
bool Matches a Boolean value. {isActive:bool}
int Matches a 32-bit integer value. {id:int}
datetime Matches a DateTime value. {startdate:datetime}
decimal Matches a decimal value. {cost:decimal}
double Matches a 64-bit floating-point value. {latitude:double}
float Matches a 32-bit floating-point value. {x:float}
long Matches a 64-bit integer value. {x:long}
guid Matches a GUID value. {id:guid}
length Matches a string with the specified length or within a specified range of lengths. {key:length(8)} {postcode:length(6,8)}
min Matches an integer with a minimum value. {age:min(18)}
max Matches an integer with a maximum value. {height:max(10)}
minlength Matches a string with a minimum length. {title:minlength(2)}
maxlength Matches a string with a maximum length. {postcode:maxlength(8)}
range Matches an integer within a range of values. {month:range(1,12)}
regex Matches a regular expression. {postcode:regex(^[A-Z]{2}\d\s?\d[A-Z]{2}$)}
Last updated: 27/02/2018 08:22:01

On this page

© 2019 - Learn Razor Pages.
All rights reserved.