I am using nopCommerce
, I want to change my default route from Index to another ActionResult
Promotion which is also present in same HomeController
, I have done these following tricks, but no solution,
in Nop.Web\Infrastructure\RouteProvider.cs
//home page
routes.MapLocalizedRoute("HomePage",
"",
new { controller = "Home", action = "Index" },
new[] { "Nop.Web.Controllers" });
//for promotion
routes.MapLocalizedRoute("Promotion",
"",
new { controller = "Home", action = "Promotion" },
new[] { "Nop.Web.Controllers" });
in Global.asax
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Promotion", id = UrlParameter.Optional }, // changed to Promotion
new[] { "Nop.Web.Controllers" }
);
I found the solution by just adding value Home as url name in default route, I wounder I changed the Action as Index in Global.asax. This works fine.
//home page
routes.MapLocalizedRoute("HomePage",
"Home", // added value in the default route
new { controller = "Home", action = "Index" },
new[] { "Nop.Web.Controllers" });
//for promotion
routes.MapLocalizedRoute("Promotion",
"",
new { controller = "Home", action = "Promotion" },
new[] { "Nop.Web.Controllers" });