Ignore route with a specific parameter
- by Vivien
Hello,
I have an @url.Action in which I pass a parameter to the action.
When the parameter is null, I would like to just do nothing and stay on the same page.
What I have done is the following:
routes.MapRoute(
null,
"Test/View/{Id}",
new { controller = "Test", action = "View" },
new { Id = @"\d+" } //id must be numerical
);
routes.IgnoreRoute("Test/View/{*pathInfo}");
The action is not executed but my problem is that I get this:
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
Requested URL: /Test/View
Which I obvisouly do not want to see.
Thanks for your help.