I have a RouteConfig like this
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index"}
);
}
}
But when i am trying use "http://example.com/controllername/action/166699406". It is getting the error below. What I am trying to achieve is, I want to make the id parameter mandatory. If they dont have an id parameter in the url, it should not hit a route and should show 404. I know we can achieve this by null checking the parameter in the controller. Is there any way manage that in route config itself.
No route in the route table matches the supplied values.
Exception Details: System.InvalidOperationException: No route in the route table matches the supplied values.