如何更改 nopCommerce 中的默认路由
how to change the default route in nopCommerce
我正在使用 nopCommerce
,我想将我的默认路线从 Index 更改为另一个 ActionResult
Promotion 也出现在同一个 HomeController
中,我已经做了以下这些技巧,但没有解决方案,
在 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" });
在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" }
);
我通过在默认路由中将值 Home 添加为 url 名称找到了解决方案,但我在 Global.asax 中将 Action 更改为 Index。这很好用。
//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" });
我正在使用 nopCommerce
,我想将我的默认路线从 Index 更改为另一个 ActionResult
Promotion 也出现在同一个 HomeController
中,我已经做了以下这些技巧,但没有解决方案,
在 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" });
在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" }
);
我通过在默认路由中将值 Home 添加为 url 名称找到了解决方案,但我在 Global.asax 中将 Action 更改为 Index。这很好用。
//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" });