DNN角色Bar模块路由

时间:2017-09-13 15:35:27

标签: dotnetnuke dotnetnuke-9 dnn-module

我正在尝试为dnn9创建dnn persona bar模块, 前端部分向网址发送请求,例如 - http://dnndev.me/API/personaBar/ControllerName/ActionName 我得到错误 - 无法找到http://dnndev.me/API/personaBar/ControllerName/ActionName的控制器  搜索名称空间:Dnn.PersonaBar.AdminLogs.Services,Dnn.PersonaBar.ConfigConsole.Services,Dnn.PersonaBar.CssEditor.Services,Dnn.PersonaBar.Extensions.Services,Dnn.PersonaBar.Licensing.Services,Dnn.PersonaBar.Pages。服务,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.Vocabularyies.Services。

问题是如何将我的命名空间添加到此列表中 注册从DnnApiController派生的自定义api控制器?

对于SPA模块,使用ServiceRouteMapper很简单,它是否适用于DNN角色栏模块?

1 个答案:

答案 0 :(得分:1)

对于PersonaBar扩展,您的webapi服务控制器应继承PersonaBarApiController。

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

您的dnn清单看起来像这样安装为PersonaBar菜单扩展名:

<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>

这会产生端点路径:/ API / PersonaBar / Users / CreateUser

完整示例源代码here