An awesome routing engine for ASP.NET MVC 3 and 4
TypeDefaultConstraintRegistryclass. Whenever SEO Extensions needs to validate a route parameter for an incoming request, it checks the aforementioned
Constraintproperty first, and, should it be missing, checks the
TypeDefaultConstraintRegistryclass to see if a default constraint for the type has been specified there.
Constraintproperty of its
Route.Paramattribute to
null:
public class MyController : Controller
{
[Route.Action("~/foo")]
public ActionResult Foo([Route.Param(Constraint = null)] int bar)
{
return Content("Baz!");
}
}
Register()static method of the
TypeDefaultConstraintRegistry(or the
Unregister()static method to completely remove the validation logic for a given type):
public static void RegisterRoutes(RouteCollection routes)
{
// ...
TypeDefaultConstraintRegistry.Register(typeof(UInt32), "\d+");
// ...
}
Register()method. This way, the framework will automatically validate your parameters before executing the target actions using your own type constraints.