dotnet / AspNetCore.Docs

Documentation for ASP.NET Core
https://docs.microsoft.com/aspnet/core
Creative Commons Attribution 4.0 International
12.6k stars 25.29k forks source link

Blazor + SignalR tutorial and sample should be WebAssembly only #32767

Closed danroth27 closed 4 months ago

danroth27 commented 4 months ago

Description

This doc was originally WebAssembly specific, but when it was upgraded to .NET 8 it switched to use the default Blazor Web App template, which is problematic. Using SignalR with Blazor makes sense when the SignalR client is in the browser running on WebAssembly. It doesn't really make sense to use SignalR from the server to connect back to a hub in the same server, and doing so can cause a variety of issues like port exhaustion. We should update this doc to specifically run the SignalR client from WebAssembly.

Page URL

https://learn.microsoft.com/en-us/aspnet/core/blazor/tutorials/signalr-blazor?view=aspnetcore-8.0&tabs=visual-studio

Content source URL

https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/blazor/tutorials/signalr-blazor.md

Document ID

85af7a99-672c-0438-dcc2-e8edfaf70c54

Article author

@guardrex

github-actions[bot] commented 4 months ago

😎🏖️🌴 Summertime! 🏐🏄‍♀️🦩

A green dinosaur 🦖 will be along shortly to assist. Stand-by ........

guardrex commented 4 months ago

It was hosted WASM. We'd kind'a need a separate server project for the hub-end of the demo, given that hosted WASM isn't a project template any longer. Is that what you have in mind?

BTW -- Seems like this current approach would be ok for a global CSR (or per-component CSR) BWA. Would that work? ... with some content that explains one wouldn't do this in an interactive SSR scenario.

danroth27 commented 4 months ago

It was hosted WASM. We'd kind'a need a separate server project for the hub-end of the demo, given that hosted WASM isn't a project template any longer. Is that what you have in mind?

Yup. Blazor Web App with interactive WebAssembly rendering enabled. It could be global or per page, but assuming all the SignalR logic is on a single page I'd go with per page. You then put the Hub in the server project and the SignalR client in the client project.