SignalR - How do I disable WebSockets

后端 未结 3 1118
日久生厌
日久生厌 2020-12-01 16:23

I upgraded to .NET 4.5, now SignalR seems insistent on using WebSockets in Firefox/Chrome - even though I\'m only on Windows 7 which doesn\'t have a WebSocket Server.

<
3条回答
  •  没有蜡笔的小新
    2020-12-01 17:12

    For anyone looking how to disable it on the server using asp.net core 3.1:

    public void Configure(IApplicationBuilder app, IHostingEnvironment env)
    {
        app.UseRouting();
    
        app.UseEndpoints(endpoints =>
        {
            endpoints.MapHub("/chathub", options =>
            {
                options.Transports =
                    HttpTransportType.WebSockets |
                    HttpTransportType.LongPolling;
            });
        });
    }
    

    source: https://docs.microsoft.com/en-us/aspnet/core/signalr/configuration?view=aspnetcore-3.1&tabs=dotnet#advanced-http-configuration-options-1

提交回复
热议问题