I'm trying to add number/int as constraint in route.
Source: https://msdn.microsoft.com/en-us/library/cc668201.aspx#adding_constraints_to_routes
public static void RegisterRoutes(RouteCollection routes)
{
routes.MapPageRoute("Product",
"{ProductName}/{ProductId}",
"~/Product.aspx",
false,
new RouteValueDictionary
{{"ProductName", "[a-z]"},{"ProductId", @"^\d+$"}}
);
}
This is ok: example.com/productX/1234
But it is opening Product.aspx even if {ProductId} is not number/int.
So I don't want to example.com/productY/xyz route to Product.aspx. What is wrong with that route?
Second question, {ProductName} can have letters, digits and dash(-) in it, how to change {ProductName} regular expression to target all letters, numbers, and dash(-)?