SignalR 可能為「 ASP.NET SignalR」與「ASP.NET Core SignalR」
這篇文章撰寫時 ,Azure SignalR Service 目前只支援 ASP.NET Core SignalR
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ItemGroup> | |
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" /> | |
<DotNetCliToolReference Include="Microsoft.Extensions.SecretManager.Tools" Version="2.0.0" /> | |
</ItemGroup> |
Step 6. 在入口網站,我們開啟建立後的 SignalR 服務 → 複製連線字串
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Azure:SignalR:ConnectionString": "上一步驟複製的連線字串" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); | |
services.AddSignalR().AddAzureSignalR(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.UseFileServer(); | |
app.UseAzureSignalR(routes => | |
{ | |
routes.MapHub("/chat"); | |
}); |
0 留言