[英]nopCommerce 3.2 plugin isn't working on nopCommerce 3.3 after configuration
[英]Change URL Routing by overriding GenericPathRoute.cs in Plugin nopCommerce 3.3
我正在嘗試創建一個將覆蓋TopicsDetails.cshtml頁面的插件。 我添加了這樣一條路線:
routes.MapRoute("Nop.Plugin.Other.CustomTopic.ViewCustomTopic", "{SeName}",
new { controller = "CustomTopic", action = "TopicDetails", SeName = UrlParameter.Optional },
new[] { "Nop.Plugin.Other.CustomTopic.Controllers" });
這是將所有{SeName}傳遞給我的CustomTopicController。即使是產品SeName。
如果我添加此而不是舊版本:
routes.MapRoute("Nop.Plugin.Other.CustomTopic.ViewCustomTopic",
new { controller = "CustomTopic", action = "TopicDetails" },
new[] { "Nop.Plugin.Other.CustomTopic.Controllers" });
我收到一個錯誤,因為TopicDetails(int itemId)Action接收到一個未提供的整數,因為我們知道GenericPathRoutes.cs提供該整數。
我怎樣才能覆蓋GenericPathRoutes.cs的規則來做到這一點,這樣只有SeName主題會命中我的Controller,或者有其他方式來做這種工作,或者甚至可以這樣做?
最近我寫了一篇文章,展示了如何覆蓋本地化路由,我以TopicDetails視圖為例。 有文章在這里 。 Inshort,您的路線提供者應如下所示;
public class RouteProvider : IRouteProvider
{
private const string NAMESPACES = "Nop.Plugin.Misc.Custom.Controllers";
private const string CONTROLLER = "MiscCustom";
public void RegisterRoutes(RouteCollection routes)
{
//Public Override
routes.MapGenericPathRoute("Plugin.Misc.Custom.GenericUrl",
"{generic_se_name}",
new { controller = "Common", action = "GenericUrl" },
new[] { NAMESPACES });
}
public int Priority
{
get { return Int32.Max; }
}
}
我不確定我是否理解你的問題可以通過添加id = UrlParameter.Optional在這里嘗試任何id參數是可選的它不會拋出該錯誤
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.