I created a plugin which add a new menu item on the admin menu, and I can't seem to be able to redirect to a view I created, I always get a "404" error.
My code is below:
Here I declare the menu item.
public void ManageSiteMap(SiteMapNode rootNode)
{
var menuItem = new SiteMapNode()
{
SystemName = "Nop.Plugin.MyPlugin",
Title = "Plugin title",
ControllerName = "PluginController",
ActionName = "Index",
Visible = true,
IconClass = "fa-cog",
RouteValues = new RouteValueDictionary() { { "area", null } },
};
rootNode.ChildNodes.Add(menuItem);
}
}
This is my route provider class
class RouteProvider : IRouteProvider
{
public int Priority
{
get
{
return int.MaxValue;
}
}
public void RegisterRoutes(IRouteBuilder routeBuilder)
{
var route = routeBuilder.MapRoute(
name: "Admin.Plugin.Index",
template: "Admin/Plugin/Index",
defaults: new { controller = "PluginController", action = "Index" },
dataTokens: new { area = "admin" },
constraints: new { }
);
}
}
}
Finally my controller
class MobijooSettingsController : BasePluginController
{
[HttpGet]
[AuthorizeAdmin]
[HttpsRequirement(SslRequirement.No)]
public IActionResult Index() {
return View("~\\Plugins\\Plugin\\Views\\Index.cshtml");
}
}
}
Thank you in advanced