首页 文章

在.NET Framework上使用ASP.NET Core的SignalR 2 Websockets

提问于
浏览
0

我有一个ASP.NET核心应用程序,在.NET Framework 4.6.2上运行 . 我设法使用owin-middleware运行SignalR 2 . 问题是它使用服务器事件而不是websockets . 有没有可以完成的设置,以便使用websockets?
enter image description here

Startup.cs 我打电话给 app.UseWebSockets() ; app.UseSignalR2() //自定义扩展方法将signalR映射到appbuilder

如果仅指定webSockets传输,则它没有任何错误,但它不会连接 .

我使用ASP.NET MVC项目使用了类似的设置,它按预期工作,只有在.NET Framework上使用ASP.NET Core时才会重现 .

我发现了一些类似的帖子,但我无法使用websockets运行它:Using SignalR on an asp.net Core app that targets the full .NET Framework

1 回答

  • 0

    这看起来像缺少UseWebSockets方法:

    public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IServiceProvider serviceProvider)
    {
            app.UseWebSockets();
    }
    

相关问题