Nopcommerce 4.30 Change default route

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
3 年 前
I know that we should use this below code to define a new route in nop 4.30:

   endpointRouteBuilder.MapControllerRoute("RouteName", "Plugins/Nop/Configure",
          new { controller = "NopProduct", action = "Configure", area = AreaNames.Admin });


But I want to change default routes of nopcommerce...
Actually I want to change Login route to use my plugin  controller and action
Before nopcommerce 4.30 I could change default routes in RouteProvider.cs like this :

I had to remove the default route this way :

   var lastLoginRoute = routeBuilder.Routes.FirstOrDefault(x => ((Route)x).Name == "Login");
    routeBuilder.Routes.Remove(lastLoginRoute);


And I had to define the route to my plugin this way :      

    routeBuilder.MapRoute("Login", "login/", new { controller = "MyPluginController", action = "MyLogin", });

But now in nop 4.30 which uses AspCore 3.1 and endpointRouteBuilder I do not know how I should change default routes to my plugin.
In fact I cannot remove default route which is defined in Nop.Web.Infrastructure.RouteProvider from the datasource of  endpointRouteBuilder

Please someone help me.
2 年 前
I have the same issue with Nop 4.40
2 年 前
I changed the priority of RouteProvider for plugin then it's solved.

 public void RegisterRoutes(IEndpointRouteBuilder endpointRouteBuilder)
        {
            //login
                endpointRouteBuilder.MapControllerRoute("Login", "/login/",
                    new { controller = "MyCustomer", action = "ValidateMobile" });
        }
        public int Priority => 2000;
2 年 前
Hi,

I was also trying to find the same thing and figured out that for nopCommerce version 4.30, we can set default route in GenericUrlRouteProvider.cs under Nop.Web.Infrastructure namespace file by changing below,

endpointRouteBuilder.MapControllerRoute(
                name: "Default",
                pattern: "{controller=Home}/{action=Index}/{id?}");


Hope, this could be helpful to resolve it in proper way.

Thanks!
2 年 前
@inject IHttpContextAccessor httpContextAccessor
@inject IWebHelper webHelper
@{
    Layout = "_ColumnsOne";
    var path = httpContextAccessor.HttpContext.Request.Path;
  <form asp-route="Prihlas" asp-route-returnurl="@path" method="post" autocomplete="off">

this work ok for nopcommerce 4.4
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.