In my MVC application , RouteConfig contains following code (by default):
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{key}",
defaults: new { controller = "Home", action = "Index", key= UrlParameter.Optional }
);
}
When a user hits my website (abc.com) or type abc/Home/Index , it invokes Home/Index. Problem is that I want to use key. I mean If a user enters abc/someKey or abc/Home/Index/someKey it should go to Home/Index where i can access that key. It works good in abc/Home/Index/someKey case but fails in abc/someKey & gives exception. Is there any other way to get that functionality ?