[Route("movies/released/{year:regex(\\d{4})}/{month:regex(\\d{2}):range(1,12)}")]
public ActionResult ByReleaseDate(int year, int month)
{
// this action was created to use custom route
return Content("year" + year + " month " + month);
}
In above code i want to restrict in year param to accept year only in between 2015 and 2016 , none other. I know how to do it in routing but can't get it through custom atrribute routing.
I can achieve this in route.config through this:
routes.MapRoute(
"MoviesByReleaseDate",
"{controller}/{action}/{year}/{month}", // iska talluq sirf URL se hy c# se nahn
new { controller = "Movies", action = "ByReleaseDate" }, // iska talluq C# se hy URL se nahn
new { year = "2015|2016", month = @"\d{2}" });
but no idea on how to do it in custom way inside controller.