Working with Piranha CMS and MVC .NET Core 6, I have successfully added a custom manager menu item and routed it to a custom controller.


    Menu.Items.Insert(2, new MenuItem
    {
        InternalId = "enquiries",
        Name = "Enquiries",
        Css = "fas fa-envelope"
    });

    Menu.Items["enquiries"].Items.Add(new MenuItem
    {
        InternalId = "settings",
        Name = "Settings",
        Route = "~/manager/Settings",
        Css = "fas fa-cogs"
    });

The click successfully lands in the custom controller and view is rendered, however it is rendered without the Manager layout – it just renders as a custom page.

Upon googling I found a few answers referencing the Manager area, which we don’t have in the MVC project. How can I reference the managers layout file so the page can render as the other menu items do – and is the layout file the actual problem?

The controller is inheriting from ‘ManagerController’ and the route is being hit successfully.

enter image description here

Tried using both return View() and return PartialView() with no change in result.
The manager menu item seems to be trying to render in the actual website, rather than the CMS manager.

I suggest you look at the main project for Identity in the Piranha repository as reference as it does all of this:

https://github.com/PiranhaCMS/piranha.core/tree/master/identity/Piranha.AspNetCore.Identity

Here you can see that this also registers itself in the manager menu:

https://github.com/PiranhaCMS/piranha.core/blob/master/identity/Piranha.AspNetCore.Identity/Module.cs#L78

And like you had found information on previous it’s important that you add your controller to the correct area, otherwise asp.net won’t render it correctly:

https://github.com/PiranhaCMS/piranha.core/blob/master/identity/Piranha.AspNetCore.Identity/Controllers/UserController.cs#L26