My .NET Core 6 code runs perfectly on Visual Studio 2022, but when my app is published to a server running IIS, my SignalR functionality stops working.
JavaScript:
const connection = new signalR.HubConnectionBuilder().withUrl("/checkproduct").build();
program.cs:
app.MapHub<ProductHub>("/checkproduct");
Error Message:
Failed to load resource: the server responded with a status of 404 (Not Found) signalr.js:3082
[2024-01-22T06:11:53.892Z] Error: Failed to complete negotiation with the server: Error: Not Found
[2024-01-22T06:11:53.893Z] Error: Failed to start the connection: Error: Not Found
2
Answers
In Windows Features make sure u have checked the WebSocket Protocol and the issue will be resolved
Based on your issue, I referred this doc and create simple demo, I publish it on IIS and it works fine.
Taking the example in the documentation, make sure your static resource directory looks like this: