我想覆盖搜索 Controller 。当我尝试安装插件时,出现错误异常,为名为 Catalog
的 Controller 找到了多种类型。
Multiple types were found that match the controller named 'Catalog'. This can happen if the route that services this request ('AdvanceSearch') does not specify namespaces to search for a controller that matches the request. If this is the case, register this route by calling an overload of the 'MapRoute' method that takes a 'namespaces' parameter.
我的路线优先级是最高(100)。
public void RegisterRoutes(RouteCollection routes)
{
// Product Search,
routes.MapRoute("Plugin.Misc.Twigoh.Search",
"Search",
new { controller = "Catalog", action = "Search" },
new[] { "Nop.Plugin.Misc.Twigoh.Search.Controllers" });
}
public int Priority
{
get
{
return 100;
}
}
最佳答案
您可以像这样覆盖您的路线:
当您覆盖路由时,您应该使用 MapLocalizedRoute
(不是 MapRoute
),它是覆盖本地化路由。在这里,您尝试定义已经定义的路线。
这里不要使用MapRoute
,而是使用MapLocalizedRoute
这种方式。
routes.MapLocalizedRoute("Plugin.Misc.Twigoh.Search",
"search/",
new { controller = "Catalog", action = "Search" },
new[] { "Nop.Plugin.Misc.Twigoh.Search.Controllers" });
编辑:
I want same route and functionality but default controller can't have "/" search feature little bit different
/search
是产品搜索的默认路由,可以在Nop.Web > Infrastructure > RouteProvider.cs
中看到
希望这有帮助!
关于asp.net - 覆盖 3.8 中 nopcommerce 插件的默认方法路由,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39912457/