Cross domain requests not working in SignalR 2.0.0-rc1

c#, cors, signalr

Solution

Something is wrong with your client configuration.

`XMLHttpRequest cannot load =1377623738064">http://localhost:8080/negotiate?connectionData=%5B%7B%22name%22%3A%22chathub%22%7D%5D&clientProtocol=1.3&=1377623738064. Origin http://localhost:7176 is not allowed by Access-Control-Allow-Origin.`

The negotiate request should be made to `http://localhost:8080/signalr/negotiate?...` not `http://localhost:8080/negotiate?...`. To fix this you can try the following before you call $.connection.hub.start:

`$.connection.hub.url = http://localhost:8080/signalr;`

Problem

I recently upgraded a project from SignalR 2.0.0-beta1 to 2.0.0-rc1. I understand that in RC1, configuration of support for cross domain requests changed. I've updated my project to use the new syntax however I'm now getting the following error when attempting to communicate with my hub: XMLHttpRequest cannot load =1377623738064">http://localhost:8080/negotiate?connectionData=%5B%7B%22name%22%3A%22chathub%22%7D%5D&clientProtocol=1.3&=1377623738064. Origin `http://localhost:7176` is not allowed by Access-Control-Allow-Origin. The client site is running at `http://localhost:7176` and the hub is listening via a console application at `http://localhost:8080`. Am I missing something here? Cross domain requests were working before I upgraded to RC1. CONSOLE APP ENTRY POINT ``` static void Main(string[] args) { var chatServer = new ChatServer(); string endpoint = "http://localhost:8080"; chatServer.Start(endpoint); Console.WriteLine("Chat server listening at {0}...", endpoint); Console.ReadLine(); } ``` CHATSERVER CLASS ``` public class ChatServer { public IDisposable Start(string url) { return WebApp.Start<Startup>(url); } } ``` STARTUP CONFIGURATION ``` public class Startup { public void Configuration(IAppBuilder app) { app.Map("/signalr", map => { map.UseCors(CorsOptions.AllowAll); map.RunSignalR(new HubConfiguration { EnableJSONP = true }); }); } } ```

Original source

Related problems