覆盖 3.8 中 nopcommerce 插件的默认方法路由
override default method route from plugin in nopcommerce in 3.8
我想覆盖搜索控制器。当我尝试安装插件时,出现错误异常 which multiple type were found for the controller named Catalog
。
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
中看到
希望对您有所帮助!
可能是您重命名了您的项目,使程序集的文件名发生了变化,您可能有两个版本。
因此从 bin 文件夹中删除旧的 .dll 并构建您的项目。
我想覆盖搜索控制器。当我尝试安装插件时,出现错误异常 which multiple type were found for the controller named Catalog
。
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
希望对您有所帮助!
可能是您重命名了您的项目,使程序集的文件名发生了变化,您可能有两个版本。
因此从 bin 文件夹中删除旧的 .dll 并构建您的项目。