I'm trying to use route constraints in an Asp.Net MVC Application.
routes.MapRoute(
"theRoute",
"MyAction/{page}",
new { controller = "TheController", action = "MyAction", page = 1 },
new { page = @"[0-9]" });
When I enter an url like ~/MyAction/aString, an YSOD is shown with an invalid operation exception. What can I do to redirect invalid url to the 404 page?
I know I can solve the issue with a string parameter in the controller action and int.TryParse, but then the route constaint is useless.
How can I choose the exceptiontype that is thrown by the route constraints?