在现有路由之前在DNN模块中注册路由

时间:2016-02-03 13:15:36

标签: signalr dotnetnuke

我正在我的DNN网站上开发一个Signal R应用程序。由于我无法修改我的global.asax文件,我注册了一条新路线。由于我使用相同的方法为我之前的模块添加控制器,因此在协商时出现错误

public class RouteMapper : IServiceRouteMapper
{
    public void RegisterRoutes(IMapRoute mapRouteManager)
    {
        RouteTable.Routes.MapHubs(new HubConfiguration());
    }
}

这是我的Route Mapper类..我需要在每个其他路线之前注册这条路线。有办法吗

1 个答案:

答案 0 :(得分:1)

自从我在DNNCHAT中配置它以来已经有一段时间了,但这就是我在该模块中所做的事情: https://github.com/ChrisHammond/dnnCHAT/blob/master/Components/RouteMapper.cs

使用System.Web.Routing; 使用DotNetNuke.Web.Api; //使用DotNetNuke.Web.Services;

namespace Christoc.Modules.DnnChat.Components
{
    public class RouteMapper : IServiceRouteMapper
    {
        public void RegisterRoutes(IMapRoute mapRouteManager)
        {
            //RouteTable.Routes.MapHubs(); //removed for SignalR 2.0.0

        }
    }
}

编辑:您可能需要设置的另一件事是告诉DNN不要重写SignalR路径

https://github.com/ChrisHammond/dnnCHAT/blob/master/Data/00.01.00.sqldataprovider

我使用该文件中的SQL

IF NOT EXISTS (SELECT * FROM {databaseOwner}[{objectQualifier}HostSettings] WHERE SettingName = 'AUM_DoNotRewriteRegEx' )

    insert into {databaseOwner}{objectQualifier}hostsettings
    (SettingName
    , SettingValue
    , SettingIsSecure 
    , CreatedByUserId
    , CreatedOnDate
    , LastModifiedByUserId
    , LastModifiedOnDate
    )
    values(
    'AUM_DoNotRewriteRegEx'
    ,'/DesktopModules/|/Providers|/LinkClick\.aspx|/SignalR'
    , 0
    , -1
    , GETDATE()
    , -1
    , GETDATE()
    )

GO

IF EXISTS (SELECT * FROM {databaseOwner}[{objectQualifier}HostSettings] WHERE SettingName = 'AUM_DoNotRewriteRegEx' and SettingValue not like '%/signalr%' )

update {databaseOwner}{objectQualifier}hostsettings
    set settingValue = (select settingValue + '|/signalr' from {databaseOwner}{objectQualifier}hostsettings where settingname = 'AUM_DoNotRewriteRegEx')
where settingname = 'AUM_DoNotRewriteRegEx'


GO