Nopcommerce Error - "Page Not Found" when redirecting from admin to plugins

I am using nopCommerce. I am developing a plugin project.

When I tried to redirect the admin page to the plugin page, this gives an error, for example,

"PAGE NOT FOUND"

URL of my plugin page

localhost:2276/Admin/Category/List

But it works correctly for this URL

localhost:2276/Plugin/Category/List

RouteProvider.cs

 public partial class RouteProvider : IRouteProvider
    {
        public void RegisterRoutes(RouteCollection routes)
        {
            routes.MapRoute("Nop.Plugin.Category.ShopByCategory.Views.Category.List",
                 "Admin/Category/List",
                new { controller = "Category", action = "List" },
                new[] { "Nop.Plugin.Category.ShopByCategory.Controllers" });
        }
        public int Priority
        {
            get { return 0; }
        }
    }

I need to implement this at this URL localhost:2276/Admin/Category/List. Is there any other way to implement this?

+4
source share
5 answers

URL-, .
, RegisterRoutes RouteProvider.

var route = routes.MapRoute(RouteName,
                  "admin/Plugins/PluginName/ControllerName/ActionName",
                  new { controller = "ControllerName", action = "ActionName" },
                  new[] { TheNamespaceOfControllerClass }
             );

route.DataTokens.Add("area", "admin");
0

public override void RegisterArea(AreaRegistrationContext context)
    {
        context.MapRoute(
            "Admin_default",
            "Admin/{controller}/{action}/{id}",
            new { controller = "Home", action = "Index", area = "Admin", id = "" },
            new[] { "Nop.Admin.Controllers" }
        );
    }
+1

, , - , Admin . , . , URL-, .

, , - :

public partial class RouteProvider : IRouteProvider
    {
        public void RegisterRoutes(RouteCollection routes)
        {
            routes.MapRoute("Nop.Plugin.Category.ShopByCategory.Views.Category.List",
                 "Category/List",
                new { controller = "Category", action = "List" },
                new[] { "Nop.Plugin.Category.ShopByCategory.Controllers" });
        }
        public int Priority
        {
            get { return 0; }
        }
    }
0

0

Nop.Admin. Nop.Admin.dll.

-1

Source: https://habr.com/ru/post/1544850/


All Articles