Geralt wrote:Thanks for the response Sklyer. This seemingly simple tasks really does seem to be a head scratcher.
My route follows what you recommended but I'm having the same issue.
var route = routes.MapRoute(
"Nop.Plugin.Misc.DealersAdmin",
"Admin/Dealer",
new { controller = "DealerAdmin", action = "Index" },
new[] { "Nop.Plugin.Misc.Dealers.Controllers" }
);
route.DataTokens.Add("Area", "Admin");
I have also tried other combinations of setting the area and using DataTokens as the code below shows, but nothing seems to work.
routes.MapRoute(
"Nop.Plugin.Misc.DealersAdmin",
"Admin/Dealer",
new { controller = "DealerAdmin", action = "Index", area = "Admin" },
new[] { "Nop.Plugin.Misc.Dealers.Controllers" }
).DataTokens.Add("Area", "Admin");
I tried setting a negative condition on the area route to not match if the controller is named "Dealer", and that seems to work. Going to "Admin/Dealer" it was able to find my plugin controller in its proper namespace. But that envolves changing the AdminAreaRegistration.cs file which I don't want to do.
Hi Geralt,
My advice was actually for the topic starter.
I think it is possible your route is too vague and matches other patterns. I'll look into this further to see if I can replicate the issue, but if you reverse your path it will probably work. Here are some routes for a plugin I'm currently working on. They are likely going to change, but they definitely work as they are written.
routes.MapRoute("Nop.Plugin.Payments.Adyen.Public", "adyen/public/{action}", new {controller = "Public", action = "Index"}, new[] { "Nop.Plugin.Payments.AdyenHosted.Controllers" });
routes.MapRoute("Nop.Plugin.Payments.Adyen.Settings", "adyen/settings/{action}", new {controller = "Settings", action = "Index"}, new[] { "Nop.Plugin.Payments.AdyenHosted.Controllers" });
routes.MapRoute("Nop.Plugin.Payments.Adyen.Account", "adyen/admin/account/{action}/{id}", new {controller = "Account", action = "Index", id = UrlParameter.Optional }, new[] { "Nop.Plugin.Payments.AdyenHosted.Controllers" });