If I have a route:
routes.MapRoute(
"RouteName", // route name
"{action}", // url with parameters
new { controller = "Home", action = "Index", id = "" } // parameter defaults
);
I want to be able to catch URL's of the form:
http://sitename.com/about
http://sitename.com/contact
http://sitename.com/others
This obviously works when an action exists within the Home controller that carries the name of the desired URL. If I enter an erroneous URL, such as http://sitename.com/foo, and the foo action does not exist within the Home controller, I would like to direct the application to a 404 page not found, but obviously if I enter foo, it is looking for the foo action within the home controller. Is there any way to remain generic without hardcoding all the subpages into the global.asax. If at all possible, I want to refrain from:
routes.MapRoute(
"About", // route name
"about", // url with parameters
new { controller = "Home", action = "About", id = "" } // parameter defaults
);
routes.MapRoute(
"Contact", // route name
"contact", // url with parameters
new { controller = "Home", action = "Contact", id = "" } // parameter defaults
);
Thanks.