I've been playing with ASP.Net MVC for a while now. I found the most difficult thing to get right is the routing table.
I found most examples leave the default route in place. I found that this leads to a lot of errors where the default route redirects to HomeController with an action that doesnt exist. Leading to strange error messages where you would expect to see a simple 404.
I eventually settled for a routing setup where I explicitly define all controller/action combinations I want to allow with a catch-all at the end to redirect to a 404 page that shows a sensible error message.
Am I missing something here? Or is this indeed a good way to do things?
Looking at the answers I got I think I'd better clarify the question a bit.
I'm trying to fool-proof the routing scheme of the website I'm building. I noticed that when I leave in the default {controller}/{action}/{id} route all kinds of URL's where I would like to display a 404 error actually get routed to the HomeController with an invalid Action and result in some ugly error message instead.
I'm a bit confused because most code examples just leave in the default route. Is there a reason it's there or is it ok to remove it?
The scheme I'm using now looks a bit like this
routes.MapRoute( "About", "About", new {controller = "Page", action = "About"} );
routes.MapRoute( "SignIn", "SignIn", new {controller = "Page", action = "SignIn"} );
routes.MapRoute( "SignOut", "SignOut", new {controller = "Page", action = "SignOut"} );
routes.MapRoute( "Authenticate", "Authenticate", new { controller = "Authentication", action = "Authenticate" });
routes.MapRoute("CatchAll", "{*url}", new { controller = "Error", action = "Http404" });
I've got a route specified for every action in the system. And a catchall to display a 404 at the end. Is this a good way to do this or is there an easier way to make the routing scheme fool-proof?