The Error
Failed to load resource: the server responded with a status of 404 (Not Found)
Error: Failed to complete negotiation with the server
Quick Fix - 1 Minute
// Program.cs - Dev Fix: Map SignalR hub BEFORE app.Run()
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddSignalR();
var app = builder.Build();
app.MapHub("/chathub"); // Must be before app.Run()
app.Run();
Why This Happens
SignalR returns 404 on /negotiate when the hub endpoint isn't mapped or middleware order is wrong. App.UseRouting() must come before app.MapHub(). In .NET 8 minimal APIs, order matters more than MVC.
Best Practice for .NET 8
- Call
app.MapHub()afterapp.UseRouting()but beforeapp.Run() - Check hub path matches client:
new HubConnectionBuilder().WithUrl("/chathub") - For Blazor Server: ensure
@rendermode InteractiveServeris set
No comments yet. Be the first to share your thoughts!