DNN Persona Bar module routing

462 views Asked by At

I am trying to create dnn persona bar module for dnn9, Front-end part sends request to the url like - http://dnndev.me/API/personaBar/ControllerName/ActionName and I get error - Unable to locate a controller for http://dnndev.me/API/personaBar/ControllerName/ActionName Searched in namespaces: Dnn.PersonaBar.AdminLogs.Services, Dnn.PersonaBar.ConfigConsole.Services, Dnn.PersonaBar.CssEditor.Services, Dnn.PersonaBar.Extensions.Services, Dnn.PersonaBar.Licensing.Services, Dnn.PersonaBar.Pages.Services, Dnn.PersonaBar.Recyclebin.Services, Dnn.PersonaBar.Roles.Services, Dnn.PersonaBar.Security.Services, Dnn.PersonaBar.Seo.Services, Dnn.PersonaBar.Servers.Services, Dnn.PersonaBar.SiteImportExport.Services, Dnn.PersonaBar.Sites.Services, Dnn.PersonaBar.SiteSettings.Services, Dnn.PersonaBar.SqlConsole.Services, Dnn.PersonaBar.TaskScheduler.Services, Dnn.PersonaBar.Themes.Services, Dnn.PersonaBar.UI.Services, Dnn.PersonaBar.Users.Services, Dnn.PersonaBar.Vocabularies.Services.

the question is how to add my namespace to this list to register custom api controller derived from DnnApiController ?

For SPA module it's simple with ServiceRouteMapper, is it posible for DNN persona bar module?

1

There are 1 answers

2
Fix It Scotty On BEST ANSWER

For a PersonaBar extension, your webapi service controllers should inherit from PersonaBarApiController.

[MenuPermission(MenuName = "Dnn.Users")]
public class UsersController : PersonaBarApiController
{
    [HttpPost]
    public HttpResponseMessage CreateUser(CreateUserContract contract)
    {
        ...
    }
}

Your dnn manifest should look something like this to install as PersonaBar menu extension:

<package name="Dnn.PersonaBar.Users" type="PersonaBar" version="01.06.00">
...
    <component type="PersonaBarMenu">
          <menu>
            <identifier>Dnn.Users</identifier>
            <moduleName>Users</moduleName>
            <controller>Dnn.PersonaBar.Users.Components.UsersMenuController, Dnn.PersonaBar.Users</controller>
            <resourceKey>nav_Users</resourceKey>
            <path>Users</path>
            <parent>Manage</parent>
            <order>10</order>
            <defaultPermissions>Administrators</defaultPermissions>
          </menu>
    </component>
...
</package>

This results in endpoint path: /API/PersonaBar/Users/CreateUser

Full example source code here