简体   繁体   English

在 .NET 4.6.1 上使用 SignalR Core

[英]Using SignalR Core on .NET 4.6.1

As said in the SignalR differences documentation we can use SignalR Core on .NET 4.6.1 and latter...SignalR 差异文档中所述,我们可以在 .NET 4.6.1 及更高版本上使用 SignalR Core ...

SignalR 差异

So I know the code for the startup and configuration for both cases:所以我知道这两种情况的启动和配置代码:

SignalR Core: SignalR 核心:

ConfigureServices配置服务

//Add SignalR service
services.AddSignalR();

Startup启动

app.UseSignalR(routes =>
{
    routes.MapHub<NotificationsHub>("/notification");
});

SignalR: SignalR:

Startup启动

app.Map("/signalr", map =>
{
    map.UseCors(CorsOptions.AllowAll);
    var hubConfiguration = new HubConfiguration { };
    hubConfiguration.EnableDetailedErrors = true;
    map.RunSignalR(hubConfiguration);
});

And my question is, what I need to do in the .NET 4.6.1 startup to map my SignalR hub and etc...?我的问题是,我需要在 .NET 4.6.1 启动到 map 我的 SignalR 集线器等...? I can't find any documentation about this particular case.我找不到有关此特定案例的任何文档。

Update1: I tried to run the same code and obviously changed the client code to use the SignalR core approach and what I get now is (not authorized) during negotiation request. Update1:我尝试运行相同的代码,显然更改了客户端代码以使用 SignalR 核心方法,我现在得到的是(未授权)在协商请求期间。

After some research and after I asked this same question on the ASP.NET forum , I came to the result of that it is not possible to use SignalR Core on any .NET Framework project.经过一些研究并在ASP.NET 论坛上提出了同样的问题后,我得出的结果是,在任何 .NET 框架项目上都无法使用 SignalR 核心。 We can use it only on .NET Core projects and it supports targeting framework to .NET Framework 4.6.1 or later then compile and run the application on supported platform.我们只能在 .NET 核心项目上使用它,它支持将框架定位到 .NET 框架 4.6.1 或更高版本,然后在支持的平台上编译和运行应用程序。

More details here: https://forums.asp.net/t/2160460.aspx更多细节在这里: https://forums.asp.net/t/2160460.aspx

While this question was already answered by the OP I think a more complete answer is warranted for the benefit of others who may stumble across it.虽然 OP 已经回答了这个问题,但我认为为了其他可能偶然发现它的人的利益,有必要提供更完整的答案。

ASP.NET Core versions 1 through 2.2 supported targetting .NET Framework v4.6.1+ to ease transitioning from ASP.NET v4 to ASP.NET Core. ASP.NET Core 版本 1 到 2.2 支持以 .NET Framework v4.6.1+ 为目标,以简化从 ASP.NET v4 到 ASP.NET Core 的过渡。 This support was dropped in ASP.NET Core v3.此支持已在 ASP.NET Core v3 中删除。

While both SignalR and SignalR Core have nuget packages targetting .NET Framework v4.6.1+ they have different dependencies.虽然 SignalR 和 SignalR Core 都有针对 .NET Framework v4.6.1+ 的 nuget 包,但它们具有不同的依赖关系。 This is made slightly more confusing due to one of the SignalR nuget packages being called Microsoft.AspNet.SignalR.Core.由于 SignalR nuget 包中的一个被称为 Microsoft.AspNet.SignalR.Core,因此这会变得更加混乱。

The long and short of it is SignalR Core was built upon ASP.NET Core.它的长短是 SignalR Core 建立在 ASP.NET Core 之上。 You cannot use SignalR Core without it.没有它你不能使用 SignalR 核心。 If you want to use SignalR Core while still targetting .NET Framework v4.6.1-v4.8 you can do so only by creating a ASP.NET Core v1-v2.2 project then changing it's target framework to.v4.6.1-v4.8.如果您想使用 SignalR 核心,同时仍以 .NET 框架 v4.6.1-v4.8 为目标,您只能通过创建 ASP.NET 核心 v1-v2.2 项目,然后将其目标框架更改为 .v4.6.1-v4.8 来实现。

For ASP.NET v4 applications as of this writing the latest supported version of SignalR is v2.4.3.在撰写本文时,对于 ASP.NET v4 应用程序,SignalR 的最新支持版本是 v2.4.3。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 升级到.NET 4.6.1后缺少SignalR UseServiceBus定义 - SignalR UseServiceBus deinition missing after upgrading to .NET 4.6.1 使SignalR与在点网框架4.6.1中运行的Angular 5配合使用 - Getting SignalR working with Angular 5 running in dot net framework 4.6.1 SignalR .NET Core - SignalR .NET Core 在带有.NET Core(.NET Standard 1.4和.NET Framework 4.6.1)的System.Net.Http中使用await / async时出现错误? - Bug when using await/async for System.Net.Http with .NET Core (.NET Standard 1.4 and .NET Framework 4.6.1)? 在 .NET 控制台客户端应用程序中使用 ASP.NET Core SignalR 从 Azure SignalR 接收消息 - Using ASP.NET Core SignalR in .NET Console Client App to Receive Messages from Azure SignalR 使用signalr和sqldependency在asp.net核心中进行数据库更改通知 - Database change notifications in asp.net core using signalr and sqldependency .net核心中的Azure ServiceBus消息未在.net 4.6.1中解析 - Azure ServiceBus message from .net core does not parse in .net 4.6.1 如何在 Asp.net Core 中使用 SignalR 向组发送通知 - How send notification to groups using SignalR in Asp.net Core 一对一聊天使用 asp.net 核心 SignalR 和 angular 2 - Chat one to one using asp.net core SignalR and angular 2 .Net Core 3.1.2 中的 GetFullPath 行为与 .Net 4.6.1 不同 - GetFullPath behavior in .Net Core 3.1.2 differs from .Net 4.6.1
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM