[英]Is SignalR with .NET 5 compatible with a Blazor application running .NET Standard 2.1?
Having a nightmare of a time setting up a simple Blazor SignalR application.在设置一个简单的 Blazor SignalR 应用程序时做了一场噩梦。
According to documentation, SignalR is greatly improved in .NET 5. It's not compatible with .NET Core 3.1.根据文档,SignalR 在 .NET 5 中得到了很大改进。它与 .NET Core 3.1 不兼容。 That's fair enough.
这很公平。
If I make a Blazor web assembly client, not hosted in .NET Core (I don't understand what that really means but I decided not to check the box to do it), then it runs on .NET Standard 2.1如果我制作一个 Blazor web 程序集客户端,而不是在 .NET Core 中托管(我不明白这到底意味着什么,但我决定不选中该框来执行此操作),然后它在 .NET Standard 2.1 上运行
So if I set up SignalR in .NET 5 and then try to consume it using my .NET Standard 2.1 Blazor client, would that work?因此,如果我在 .NET 5 中设置 SignalR,然后尝试使用我的 .NET Standard 2.1 Blazor 客户端使用它,这样行得通吗? If not what should I do?
如果不是我该怎么办?
-- --
If I make a Blazor web assembly client, not hosted in .NET Core (I don't understand what that really means but I decided not to check the box to do it), then it runs on .NET Standard 2.1
如果我制作一个 Blazor web 程序集客户端,而不是在 .NET Core 中托管(我不明白这到底意味着什么,但我决定不选中该框来执行此操作),然后它在 .NET Standard 2.1 上运行
If you create a WASM app using .NET Core 3.1 :如果您使用.NET Core 3.1创建 WASM 应用程序:
.NET Core hosted: There will be 3 projects created: .NET 核心托管:将创建3个项目:
.Client
is netstandard2.1
and using Microsoft.NET.Sdk.Web
SDK .Client
是netstandard2.1
并使用Microsoft.NET.Sdk.Web
SDK.Server
will be netcoreapp3.1
and using Microsoft.NET.Sdk.Web
SDK .Server
将是netcoreapp3.1
并使用Microsoft.NET.Sdk.Web
SDK.Shared
will be netstandard2.1
and using Microsoft.NET.Sdk
SDK .Shared
将是netstandard2.1
并使用Microsoft.NET.Sdk
SDK NOT .NET Core hosted: There will be 1 project created, which is netstandard2.1
and using Microsoft.NET.Sdk.Web
SDK不是 .NET 核心托管:将创建 1 个项目,它是
netstandard2.1
并使用Microsoft.NET.Sdk.Web
SDK
If you create a WASM app using .NET 5如果您使用.NET 5创建 WASM 应用程序
.NET Core hosted: There will be 3 projects created: .NET 核心托管:将创建3个项目:
.Client
is net5.0
and using Microsoft.NET.Sdk.BlazorWebAssembly
SDK .Client
是net5.0
并使用Microsoft.NET.Sdk.BlazorWebAssembly
SDK.Server
is net5.0
and using Microsoft.NET.Sdk.Web
SDK .Server
是net5.0
并且使用Microsoft.NET.Sdk.Web
SDK.Shared
is net5.0
and using Microsoft.NET.Sdk
SDK .Shared
是net5.0
并使用Microsoft.NET.Sdk
SDK NOT .NET Core hosted: There will be 1 project created, which is net5.0
and using Microsoft.NET.Sdk.BlazorWebAssembly
SDK不是 .NET 核心托管:将创建 1 个项目,它是
net5.0
并使用Microsoft.NET.Sdk.BlazorWebAssembly
SDK
So if I set up SignalR in .NET 5 and then try to consume it using my .NET Standard 2.1 Blazor client, would that work?
因此,如果我在 .NET 5 中设置 SignalR,然后尝试使用我的 .NET Standard 2.1 Blazor 客户端使用它,这样行得通吗? If not what should I do?
如果不是我该怎么办?
This should not be a problem.这应该不是问题。 To avoid any further confusion you can easily upgrade your .NET Core 3.1 WASM app to .NET 5 following these steps:
为避免进一步混淆,您可以按照以下步骤轻松地将 .NET Core 3.1 WASM 应用程序升级到 .NET 5:
On .csproj
file:在
.csproj
文件上:
<Project Sdk="Microsoft.NET.Sdk.Web">
to <Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
<Project Sdk="Microsoft.NET.Sdk.Web">
更改为<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
<TargetFramework.netstandard2.1</TargetFramework>
to <TargetFramework.net5.0</TargetFramework>
<TargetFramework.netstandard2.1</TargetFramework>
更改为<TargetFramework.net5.0</TargetFramework>
<RazorLangVersion>3.0</RazorLangVersion>
<RazorLangVersion>3.0</RazorLangVersion>
Microsoft.AspNetCore.Components.WebAssembly.Build
Microsoft.AspNetCore.Components.WebAssembly.Build
的引用5.0.0
5.0.0
Make sure you have these setup properly on your machine确保你的机器上有正确的设置
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.