dudi
dudi

Reputation: 21

SignalR doesn't work while published on IIS

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

Upvotes: 2

Views: 1090

Answers (2)

Xudong Peng
Xudong Peng

Reputation: 2360

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: ​enter image description here

Upvotes: 0

Suryateja KONDLA
Suryateja KONDLA

Reputation: 1576

enter image description here

In Windows Features make sure u have checked the WebSocket Protocol and the issue will be resolved

Upvotes: 2

Related Questions