简体   繁体   English

NopCommerce 4.20插件路由无法从Nop.Web使用

[英]NopCommerce 4.20 Plugin Route not working from Nop.Web

I am new to NopCommerce. 我是NopCommerce的新手。 I have a NopCommerce plugin route that returns 404. What do other than create the RouteProvider below. 我有一个返回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" });
    }
  }

and a ViewComponent below. 和下面的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);
    }
}

but my controller is not getting hit at all. 但我的控制器根本没有受到任何打击。

 public class BookAppointmentController : BasePluginController
 {
     public BookAppointmentController(){}
    [HttpGet]
    public IActionResult Create()
    {   var record = new CarInspection();
        return View("~/Plugins/Misc.BookAppointment/Views/Index.cshtml", record);
    }
 }

Is there anything I'm missing? 有什么我想念的吗? I do not have admin area for this, it is just strictly do submit a form from anywhere within the e-commerce site. 我没有管理区,只是严格从电子商务网站中的任何位置提交表单。

Very strange, should work. 很奇怪,应该工作。 Do you request on the path {site}/Plugins/Misc.BookAppointment/Create ? 您是否在路径{site}/Plugins/Misc.BookAppointment/Create

Is the plugin installed ^_^? 插件安装了^ _ ^吗? Check {site}/Admin/Plugin/List 检查{site}/Admin/Plugin/List

Note that you must set the Build Action property to the Content value and Copy if newer for the Index.cshtml and Create.cshtml 请注意,您必须将Build Action属性设置为Content值, Copy if newer Index.cshtmlCreate.cshtml Copy if newer ,则必须Copy if newer

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM