aligray aligray - 8 months ago 153
C# Question

SignalR Negotiate 404 on Subdomain

I've created a small MVC SignalR app which I'm having trouble running on my server under a subdomain:, which maps to a folder called /chat.

I've also made a console program using SignalR Client which connects and works perfectly, strangely enough.

The error from the MVC app is a 404 from[...]. I can see why this is happening but have no idea how to fix it. In my generated hubs file, the line

signalR.hub = $.hubConnection("/chat/signalr", { useDefaultPath: false });

is technically correct, but should read
$.hubConnection("/signalr", { useDefaultPath: false });

Any ideas on how to alter this? Or should I just use the raw connection API.

Also why does it work properly from the console app?

Thanks in advance.


You can continue to use the generated hubs file. You just need to modify the hubConnection's url (which stored at $.connection.hub.url) before you start your SignalR connection.

// This is initially set to "/chat/signalr" as specified in the hubs file
$.connection.hub.url = "/signalr";