[英]NopCommerce 4.20 Plugin Route not working from Nop.Web
我是NopCommerce的新手。 我有一個返回404的NopCommerce插件路由。除了在下面創建RouteProvider以外,還要做什么。
public partial class RouteProvider : IRouteProvider
{
public int Priority => -1;
public void RegisterRoutes(IRouteBuilder routeBuilder)
{
routeBuilder.MapRoute("Plugin.Misc.BookAppointment.Create",
"Plugins/Misc.BookAppointment/Create",
new { controller = "BookAppointment", action = "Create" });
}
}
和下面的ViewComponent
。
[ViewComponent(Name = "BookAppointment")]
public class BookAppointmentViewComponent : NopViewComponent
{
private readonly IProductService _productService;
public BookAppointmentViewComponent(IProductService productService)
{
_productService = productService;
}
public IViewComponentResult Invoke()
{
var record = new CarInspection();
return View("~/Plugins/Misc.BookAppointment/Views/Create.cshtml", record);
}
}
但我的控制器根本沒有受到任何打擊。
public class BookAppointmentController : BasePluginController
{
public BookAppointmentController(){}
[HttpGet]
public IActionResult Create()
{ var record = new CarInspection();
return View("~/Plugins/Misc.BookAppointment/Views/Index.cshtml", record);
}
}
有什么我想念的嗎? 我沒有管理區,只是嚴格從電子商務網站中的任何位置提交表單。
很奇怪,應該工作。 您是否在路徑{site}/Plugins/Misc.BookAppointment/Create
?
插件安裝了^ _ ^嗎? 檢查{site}/Admin/Plugin/List
請注意,您必須將Build Action
屬性設置為Content
值, Copy if newer
Index.cshtml
和Create.cshtml
Copy if newer
,則必須Copy if newer
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.