Are these two pieces of codes the same?
RouteValueDictionary dic=new RouteValueDictionary();
dic.Add("controller", "Home");
dic.Add("action", "Index");
RouteTable.Routes.MapRoute("Test", "Test/Something", dic);
and
RouteTable.Routes.MapRoute("Test", "Test/Something", new{controller="Home", action="Index"});
I am not getting the same route in the route table. When I use the first option, the keys “controller” and “action” arent in RouteTable.Routes[0].Defaults.Keys but are added on the RouteTable.Routes[0].Defaults.Values
Do you know what I am doing wrong in the first option?
you can pass object of any type for third parameter but the passed object must have included keys defined in you’r url pattern as it’s properties.for example
in this case you’r object must include
controller,action,idproperties.