简体   繁体   中英

specify a route's controller namespace in ASP.NET core

I am working in a nopCommerce 4.0 plugin, in my plugin, I want to override the OnePageCheckout action in Checkout controller. in the previous version Mvc, this will work with following code

routeBuilder.MapRoute("Plugin.Misc.TrialTracker.OnePageCheckout",
            "onepagecheckout/",
            new { controller = "Checkout", action = "OnePageCheckout" }, new[] { "Nop.Plugin.Misc.TrialTracker.Controllers" });

however, it doesnt work anymore in ASP.NET core. This is similar problems with the post here. I can't use the solution there as I dont want to touch the default nopCommerce Checkout controller.

To recap, i got 2 Checkout controller, one is under namespace Nop.Web.Controller , another one is under namespace Nop.Plugin.Misc.TrialTracker.Controllers . and there is one default RouteProvider registered the route \\onepagecheckout whith Nop.Web.Controller.CheckoutController controller's OnePageCheckout action. Without touching the default RouteProvider and Nop.Web.Controller.CheckoutController , how can I make the route \\onepagecheckout use my own controller action?

Thanks

Check below link https://www.nopcommerce.com/boards/t/50136/overriding-controller-and-view-in-nopcommerce-40.aspx#202614

Do not create controller with same name as in Nop.web

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM