new Route 404 error

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
7 anni tempo fa
Hello!
I create a plugin and introduce a new route

namespace Nop.Plugin.Misc.ODBCOrderExport
{
    class RouteProvider : IRouteProvider
    {
        public int Priority
        {
            get
            {
                return 0;
            }
        }

        public void RegisterRoutes(RouteCollection routes)
        {
            routes.MapLocalizedRoute("Plugin.Misc.ODBCOrderExport.OrderViewDetails",
                "Admin/Order/Edit/ODBC/{orderId}",
                new { controller = "ODBCOrderExport", action = "OrderViewDetails", orderId = UrlParameter.Optional },
                new { orderId = @"\d+" },
                new[] { "Nop.Plugin.Misc.ODBCOrderExport.Controllers" }
            );
        }
    }
}



Then I go to the link like http://localhost:15536/Admin/Order/Edit/ODBC/35 and receive 404 error. I make break point in controller method but i dont come to it. What can be wrong?
7 anni tempo fa
art_MOO wrote:
Hello!
I create a plugin and introduce a new route

namespace Nop.Plugin.Misc.ODBCOrderExport
{
    class RouteProvider : IRouteProvider
    {
        public int Priority
        {
            get
            {
                return 0;
            }
        }

        public void RegisterRoutes(RouteCollection routes)
        {
            routes.MapLocalizedRoute("Plugin.Misc.ODBCOrderExport.OrderViewDetails",
                "Admin/Order/Edit/ODBC/{orderId}",
                new { controller = "ODBCOrderExport", action = "OrderViewDetails", orderId = UrlParameter.Optional },
                new { orderId = @"\d+" },
                new[] { "Nop.Plugin.Misc.ODBCOrderExport.Controllers" }
            );
        }
    }
}



Then I go to the link like http://localhost:15536/Admin/Order/Edit/ODBC/35 and receive 404 error. I make break point in controller method but i dont come to it. What can be wrong?


Try like bellow==>


namespace Nop.Plugin.Misc.ODBCOrderExport
{
   public class RouteProvider : IRouteProvider
    {
        public int Priority
        {
            get
            {
                return 99;
            }
        }

        public void RegisterRoutes(RouteCollection routes)
        {
           var route= routes.MapRoute("Plugin.Misc.ODBCOrderExport.OrderViewDetails",
                "Admin/Order/Edit/ODBC/{orderId}",
                new { controller = "ODBCOrderExport", action = "OrderViewDetails", orderId = UrlParameter.Optional },
                new { orderId = @"\d+" },
                new[] { "Nop.Plugin.Misc.ODBCOrderExport.Controllers" }
            );
            route.DataTokens.Add("area", "admin");
            routes.Remove(route);
            routes.Insert(0, route);
        }
    }
}
7 anni tempo fa
No result. Still 404. Thats really strange.
Plugin look like


public class ODBCOrderExportPlugin : BasePlugin, IConsumer<AdminTabStripCreated>
    {
        private IRepository<ScheduleTask> _scheduleTaskService;
        private IPluginFinder _pluginFinder;

        public ODBCOrderExportPlugin(IRepository<ScheduleTask> scheduleTaskService,
                                     IPluginFinder pluginFinder)
        {
            this._scheduleTaskService = scheduleTaskService;
            this._pluginFinder = pluginFinder;
        }


And controller look like


namespace Nop.Plugin.Misc.ODBCOrderExport.Controllers
{
    class ODBCOrderExportController : BaseController
    {

        private IOrderExtensionService _orderExtensionService;
        private IRepository<OrderExtensionRecord> _orderExtensionRepository;
        private readonly IOrderService _orderService;
        private readonly IOrderProcessingService _orderProcessingService;
        private readonly IWebHelper _webHelper;
        private readonly IWorkContext _workContext;
        private readonly IOrderModelFactory _orderModelFactory;
        public ODBCOrderExportController(IRepository<OrderExtensionRecord> orderExtensionRepository,
                                         IOrderExtensionService orderExtensionService,
                                         IOrderService orderService,
                                         IOrderProcessingService orderProcessingService,
                                         IWebHelper webHelper,
                                         IWorkContext workContext,
                                         IOrderModelFactory orderModelFactory)
        {
            this._orderExtensionRepository = orderExtensionRepository;
            this._orderExtensionService = orderExtensionService;
            this._orderService = orderService;
            this._orderProcessingService = orderProcessingService;
            this._webHelper = webHelper;
            this._workContext = workContext;
            this._orderModelFactory = orderModelFactory;
        }

        [NopHttpsRequirement(SslRequirement.Yes)]
        public virtual ActionResult ReloadOrderToODBC(int orderId)
7 anni tempo fa
class ODBCOrderExportController makes it public.


And clean build whole solution.


Note: if above solution not work for you then try with change url "Order/Edit/ODBC/{orderId}". I mean remove "Admin" from url then try

Like===>


routes.MapLocalizedRoute("Plugin.Misc.ODBCOrderExport.OrderViewDetails",
                "Order/Edit/ODBC/{orderId}",
                new { controller = "ODBCOrderExport", action = "OrderViewDetails", orderId = UrlParameter.Optional },
                new { orderId = @"\d+" },
                new[] { "Nop.Plugin.Misc.ODBCOrderExport.Controllers" }
            );
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.