Skip to content

docs: modernize SignalR integration tutorial - #23992

Open
Jen-Uno wants to merge 1 commit into
masterfrom
docs/signalr-tutorial-modernize
Open

docs: modernize SignalR integration tutorial#23992
Jen-Uno wants to merge 1 commit into
masterfrom
docs/signalr-tutorial-modernize

Conversation

@Jen-Uno

@Jen-Uno Jen-Uno commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

What this PR does

Modernizes the SignalR integration tutorial (doc/articles/signalr.md):

  • Rewrites the intro to describe ASP.NET Core SignalR and its transports, and when it's a good fit for Uno apps.
  • Updates prerequisites to .NET 9 SDK, Visual Studio 2022 17.8+ / VS Code / Rider, and clarifies that an Azure account is not required (local dev + production hosting pointers).
  • Replaces the Startup.cs / ConfigureServices pattern with the current Program.cs minimal-hosting model.
  • Uses the dotnet new web + dotnet add package Microsoft.AspNetCore.SignalR.Client CLI flow, structured into clear "Create the server" / "Add SignalR to the Uno client" steps.
  • Notes cross-platform client support (WASM, Desktop/Skia, iOS, Android) and adds production CORS guidance.

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

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
Copilot AI lite review requested due to automatic review settings August 6, 2026 17:14
@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-23992/docs/index.html

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.cs guidance with Program.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.

Comment thread doc/articles/signalr.md

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 thread doc/articles/signalr.md
## 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 thread doc/articles/signalr.md
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 thread doc/articles/signalr.md
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 thread doc/articles/signalr.md
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. |
Comment thread doc/articles/signalr.md
private async void ChatPage_Loaded(object sender, RoutedEventArgs e)
{
_connection = new HubConnectionBuilder()
.WithUrl("https://localhost:5001/chatHub")
Comment thread doc/articles/signalr.md

```csharp
var connection = new HubConnectionBuilder()
.WithUrl("https://localhost:5001/chatHub")
Comment thread doc/articles/signalr.md
|----------|-----------|-------|
| 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)). |
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Docs] Feedback: SignalR Docs Tutorial/Sample

3 participants