nopcommerce MVC路线说明

时间:2012-02-24 09:56:52

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

运行nopcommerce 2.4.0时,我得到的链接是localhost:7725/c/2/computers而不是localhost:7725/categories/2/computers

我不知道代码在哪里将类别转换为 c

请帮助我通过nopcommerce学习MVC。

1 个答案:

答案 0 :(得分:7)

  1. 打开\Presentation\Nop.Web\Infrastructure\RouteProvider.cs档案
  2. 查找
  3. routes.MapLocalizedRoute("Category",
                     "**c**/{categoryId}/{SeName}",
                     new { controller = "Catalog", action = "Category", SeName = UrlParameter.Optional },
                     new { categoryId = @"\d+" },
                     new[] { "Nop.Web.Controllers" });
    
    

    并将其替换为

    routes.MapLocalizedRoute("Category",
                                "categories/{categoryId}/{SeName}",
                                new { controller = "Catalog", action = "Category", SeName = UrlParameter.Optional },
                                new { categoryId = @"\d+" },
                                new[] { "Nop.Web.Controllers" });
    

    3。在\Libraries\Nop.Services\Seo\SitemapGenerator.cs文件中执行几乎相同的操作(将{0}c/{1}/{2}替换为{0}categories/{1}/{2}