- You can apply multiple constraints to a parameter, separated by a colon.
- Well,It's like this [Route("Pet/{petId:int:min(1)}")]
PetController.cs
public class PetController : Controller
{
}
public class PetController : Controller
{
// eg: /Pet/8
[Route("Pet/{petId:int:min(1)}")]
public ActionResult GetSpecificPetById(int petId)
{
return View();
}
Key points of the above code
- In the above example,You can't use /Pet/10000000000 ,because it is larger than int.MaxValue
- And also you can't use /Pet/0 ,because of the min(1) constraint.