How can I get the routing work in Nopcommerce 4.0?

Posted: March 13, 2018 at 10:51 PM Quote #201900
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.
This post/answer is useful
0
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
Posted: March 13, 2018 at 11:13 PM Quote #201901
Hello,

Please checkout here.

How route work in nop 4.0.

http://docs.nopcommerce.com/pages/viewpage.action?pageId=1442547
This post/answer is useful
0
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
Please up-vote the answer, if it helpful to you! :)

Cheers,
sk5202
Posted: March 13, 2018 at 11:47 PM Quote #201906
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"
This post/answer is useful
0
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
Posted: May 11, 2018 at 10:38 AM Quote #204195
[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
This post/answer is useful
0
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
Posted: August 20, 2018 at 6:41 AM Quote #210803
[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.
This post/answer is useful
0
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
Posted: August 20, 2018 at 9:15 AM Quote #210810
[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 post/answer is useful
0
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
Dia [email protected]

Please vote for my comment if it is helpful for you.
Premium support services
  • Dedicated premium support services provided by core developers are intended for persons who run mission critical websites, work on projects with tight deadlines, or want to get dedicated support.
Professional services
  • Want to open a new store? Want to take your store to the next level? Need a custom extension? We can customize nopCommerce to fit your store perfectly. Request a quote to get started.
eCommerce CONFERENCE 2018
Learn more