docs: modernize SignalR integration tutorial - #23992
Open
Jen-Uno wants to merge 1 commit into
Open
Conversation
Rewrites the SignalR tutorial to address multiple issues reported in #22607: - Updates from .NET 5/VS2019/Startup.cs to .NET 9+ minimal API (Program.cs) - Removes confusing AddRazorPages()/MapRazorPages() references - Adds complete Uno client-side code (HubConnection, XAML UI) - Adds CORS configuration guidance for WASM cross-origin scenarios - Documents supported platforms and transport details - Adds reconnection handling patterns - Links to Microsoft docs and the ChatSignalR sample app Fixes #22607
Contributor
|
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-23992/docs/index.html |
Contributor
There was a problem hiding this comment.
Pull request overview
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Modernizes the Uno Platform SignalR integration tutorial to reflect current ASP.NET Core hosting patterns, tooling, and cross-platform client considerations.
Changes:
- Updates the intro/prereqs and restructures the tutorial into server/client/run steps using modern .NET + minimal hosting.
- Replaces
Startup.csguidance withProgram.cs, adds CORS guidance, and includes reconnection + platform notes. - Adds updated samples (Hub,
Program.cs, Uno client code-behind + XAML) and links to further reading.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| 1. Create `ASP.NET Core web application` in Visual Studio and name it `UnoChat.Service`. | ||
| Create a new ASP.NET Core Web API project that will host the SignalR hub: | ||
|
|
| ## Step 1 — Create the SignalR server | ||
|
|
||
| 1. Create `ASP.NET Core web application` in Visual Studio and name it `UnoChat.Service`. | ||
| Create a new ASP.NET Core Web API project that will host the SignalR hub: |
Comment on lines
+71
to
+82
| builder.Services.AddCors(options => | ||
| { | ||
| options.AddPolicy("CorsPolicy", policy => | ||
| { | ||
| endpoints.MapRazorPages(); | ||
| endpoints.MapHub<Hubs.[YourProjectHub]>("/yourProjectHub"); | ||
| policy | ||
| .AllowAnyHeader() | ||
| .AllowAnyMethod() | ||
| // In production, replace with your app's specific origin(s). | ||
| .SetIsOriginAllowed(_ => true) | ||
| .AllowCredentials(); | ||
| }); | ||
| ``` | ||
| }); |
Comment on lines
+93
to
+94
| > [!IMPORTANT] | ||
| > When your Uno WASM app is served from a different origin than the SignalR server, CORS must be configured on the server. The example above uses `SetIsOriginAllowed(_ => true)` for development convenience. In production, restrict this to your app's actual origin(s) and use `AllowCredentials()` since SignalR requires it for certain transports. |
Comment on lines
+259
to
+264
| | Platform | Transport | Notes | | ||
| |----------|-----------|-------| | ||
| | WebAssembly | WebSockets | Requires CORS on the server. The `Microsoft.AspNetCore.SignalR.Client` NuGet package works in Uno WASM without additional configuration. | | ||
| | Desktop (Skia) | WebSockets | Works out of the box on Windows, macOS, and Linux. | | ||
| | iOS / Android | WebSockets | Works out of the box. Ensure the server URL is reachable from the device or emulator (avoid `localhost`; use the machine's IP or a tunnel such as [dev tunnels](https://learn.microsoft.com/azure/developer/dev-tunnels/overview)). | | ||
| | Windows (WinUI) | WebSockets | Works out of the box. | |
| private async void ChatPage_Loaded(object sender, RoutedEventArgs e) | ||
| { | ||
| _connection = new HubConnectionBuilder() | ||
| .WithUrl("https://localhost:5001/chatHub") |
|
|
||
| ```csharp | ||
| var connection = new HubConnectionBuilder() | ||
| .WithUrl("https://localhost:5001/chatHub") |
| |----------|-----------|-------| | ||
| | WebAssembly | WebSockets | Requires CORS on the server. The `Microsoft.AspNetCore.SignalR.Client` NuGet package works in Uno WASM without additional configuration. | | ||
| | Desktop (Skia) | WebSockets | Works out of the box on Windows, macOS, and Linux. | | ||
| | iOS / Android | WebSockets | Works out of the box. Ensure the server URL is reachable from the device or emulator (avoid `localhost`; use the machine's IP or a tunnel such as [dev tunnels](https://learn.microsoft.com/azure/developer/dev-tunnels/overview)). | |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does
Modernizes the SignalR integration tutorial (
doc/articles/signalr.md):Startup.cs/ConfigureServicespattern with the currentProgram.csminimal-hosting model.dotnet new web+dotnet add package Microsoft.AspNetCore.SignalR.ClientCLI flow, structured into clear "Create the server" / "Add SignalR to the Uno client" steps.Why it's a separate PR
This content was originally authored on the Algolia DocSearch branch (PR #22789 / issue #22788) but is unrelated to search infrastructure. Per the review recap in
unoplatform/uno-private#2038, unrelated content changes should be tracked and merged separately — so it's split out here.Fixes #22607
🤖 Generated with Claude Code