Most of the routes I use are based on the default route defined in a standard MVC3 application:
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional });
However, if I have route that is "/Book/Update/1" and the '1' is left off because a user typed in the address manually without the 1, the null parameters error is thrown. Obviously my route requires this 1 and is not optional, but I don't won't to define a custom route for every one of my actions. If I turn on custom errors I am not sure what type of error this is to redirect to the proper html error page.
Question: How do I handle this error like it's a 404? I don't see any problem with this approach because the reality is that leaving off an Id number in a route is the same as a 404 not found.
Or am I missing something in designing my routes? Seems pretty straight forward to me.
Thanks.
Update: I appreciate the answers given below. They are both reasonable approaches. For more clarity on my question let me elaborate a bit more. A route of "/Book/Update/1" should in my opinion have only 1 single purpose. Update book 1. Any other deviation from that should fail and redirect to a 404. I don't see this as being any different than a static html page that doesn't exist. I may arguing about a feature that just isn't included in .net, I just thought there could be simpler way.
Update2: Should have dug a little deeper. There is a great example here. I found the second answer the most helpful.