How can I get the routing work in Nopcommerce 4.0?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
6 years ago
I am a newer for Nopcommerce. I created a menu item into the administration area from a plugin:

public class PaymentMethod : BasePlugin, IAdminMenuPlugin
    {
        public void ManageSiteMap(SiteMapNode rootNode)
        {
            var pluginMainMenu = new SiteMapNode()
            {
                Title = "PB",
                Url  = "~/Plugins/PaymentCredit/Index",
                Visible = true,
                SystemName = "Admin.GroupBuyingHub",
                IconClass = "fa-genderless"
            };

            rootNode.ChildNodes.Add(pluginMainMenu);
        }
    }



I also created the RouteProvider.cs:

public partial class RouteProvider : IRouteProvider
    {
        public void RegisterRoutes(IRouteBuilder routeBuilder)
        {
            routeBuilder.MapRoute("PaymentCreditAdmin","Plugins/PaymentCredit/Index",new {controller="PaymentCredit", action="Index"});
        }

        public int Priority
        {
            get { return 99; }
        }
    }


This is my Controller:

class PaymentCreditController : BaseAdminController
    {
        public ActionResult Index()
        {
            return View("~/Plugins/Payments.CreditCard/Views/Index.cshtml");
        }
    }

And I create a simplest view "Index.cshtml" in Views folder as follow:

<!DOCTYPE html>

<html>
<head>
    <title>View</title>
</head>
<body>
<div>
      
</div>
</body>
</html>

when I run it and click the item, the Url address goes to "http://localhost:15536/Plugins/PaymentCredit/Index". However, it shows "Page not found" page. Is there anything wrong?
Thanks for any help.
6 years ago
Hello,

Please checkout here.

How route work in nop 4.0.

http://docs.nopcommerce.com/pages/viewpage.action?pageId=1442547
6 years ago
Thanks for your help.
I have tried

routeBuilder.MapLocalizedRoute("PaymentCreditAdmin", "Plugins/PaymentCredit/Index", new {controller="PaymentCredit", action="Index"});

But it still show "Page not found"
5 years ago
[email protected] wrote:

when I run it and click the item, the Url address goes to "http://localhost:15536/Plugins/PaymentCredit/Index". However, it shows "Page not found" page. Is there anything wrong?
Thanks for any help.


Brian,

Did you ever figure this out?

I am having the same problem.  I wish someone would come up with an answer for this.  I have read numerous posts here on how to use the routing for nopCommerce 4.0, but none of them have helped me to get this working.

I am using nopCommerce 4.0 with source.

It would be nice if someone could explain what goes into each of the parameters of the MapRoute method, showing a Plugin with a controller, an action in the controller and a view.

It is not clear to me what the MapRoute Template parameter is and what part of the plugin goes into it.

Thanks,
Tony
5 years ago
[email protected] wrote:
Thanks for your help.
I have tried

routeBuilder.MapLocalizedRoute("PaymentCreditAdmin", "Plugins/PaymentCredit/Index", new {controller="PaymentCredit", action="Index"});

But it still show "Page not found"


Anyone find this solution?
I'm getting same error.
5 years ago
[email protected] wrote:
I am a newer for Nopcommerce. I created a menu item into the administration area from a plugin:

public class PaymentMethod : BasePlugin, IAdminMenuPlugin
    {
        public void ManageSiteMap(SiteMapNode rootNode)
        {
            var pluginMainMenu = new SiteMapNode()
            {
                Title = "PB",
                Url  = "~/Plugins/PaymentCredit/Index",
                Visible = true,
                SystemName = "Admin.GroupBuyingHub",
                IconClass = "fa-genderless"
            };

            rootNode.ChildNodes.Add(pluginMainMenu);
        }
    }



I also created the RouteProvider.cs:

public partial class RouteProvider : IRouteProvider
    {
        public void RegisterRoutes(IRouteBuilder routeBuilder)
        {
            routeBuilder.MapRoute("PaymentCreditAdmin","Plugins/PaymentCredit/Index",new {controller="PaymentCredit", action="Index"});
        }

        public int Priority
        {
            get { return 99; }
        }
    }


This is my Controller:

class PaymentCreditController : BaseAdminController
    {
        public ActionResult Index()
        {
            return View("~/Plugins/Payments.CreditCard/Views/Index.cshtml");
        }
    }

And I create a simplest view "Index.cshtml" in Views folder as follow:

<!DOCTYPE html>

<html>
<head>
    <title>View</title>
</head>
<body>
<div>
      
</div>
</body>
</html>

when I run it and click the item, the Url address goes to "http://localhost:15536/Plugins/PaymentCredit/Index". However, it shows "Page not found" page. Is there anything wrong?
Thanks for any help.


try this

routeBuilder.MapRoute("Plugin.Payment.CreditCard.Index", "PaymentCredit/Index",
             new { controller = "PaymentCredit", action = "Index" });
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.