【问题标题】:how to change the default route in nopCommerce如何更改 nopCommerce 中的默认路由
【发布时间】:2016-08-25 10:22:21
【问题描述】:

我正在使用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" }
            );

【问题讨论】:

  • 评论默认路由
  • @Div 异常:No route in the route table matches the supplied values

标签: asp.net-mvc asp.net-mvc-routing nopcommerce


【解决方案1】:

我通过在默认路由中添加值 Home 作为 url 名称找到了解决方案,我发现我将 Action 更改为 Global.asax 中的索引。这很好用。

//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" });

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-04-01
    • 2012-06-25
    • 2012-03-17
    • 1970-01-01
    • 1970-01-01
    • 2019-07-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多