4

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

When I tried to redirect Admin page to plugin page, It gives error like

"PAGE NOT FOUND"

My Plugin page URL is

localhost:2276/Admin/Category/List

But it works properly 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 by this URL localhost:2276/Admin/Category/List. Is there different way to implement this?

Tushar
  • 410
  • 4
  • 20

5 Answers5

1

you can try

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" }
        );
    }
Tina
  • 89
  • 1
  • 11
0

I have run into this issue before and I know other people have as well - the issue is with including Admin in the route. When I removed admin it worked fine. The down side to this is that your plugin admin pages don't include admin in the url, but they should still work fine.

So for example, try something like this:

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; }
        }
    }
Alex Wolf
  • 111
  • 3
0

If we want to use admin token in URL,we need to add a data token to route.
Here is a code sample how to do this in the RegisterRoutes method of RouteProvider class.

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

route.DataTokens.Add("area", "admin");
Tushar
  • 410
  • 4
  • 20
0

with me, just need to clean and rebuild solution again

Wolf
  • 6,361
  • 2
  • 28
  • 25
-1

Build Nop.Admin project. It generates the Nop.Admin.dll file.

mcemmy
  • 9,232
  • 1
  • 11
  • 4