I’m trying to achieve the following:
1. Server (WinForms for now) that hosts a SignalR persistent connection
2. ASP.NET MVC client
The server runs on port 8000 and the client runs (via Visual Studio) on port 22914.
But when I test this, I get the following error:
XMLHttpRequest cannot load http://localhost:8000/echo/negotiate?_=1352825948654. Origin http://localhost:22914 is not allowed by Access-Control-Allow-Origin.
So far so good, I need to specify that Cross Domain communication is allowed. I assume this needs to be done on the server. But where and how?
I can’t find a solution and unfortunately, there aren’t a lot of resources on the web about self hosting a SignalR connection in a WinForms app.
I recently encountered this problem myself; the answer is to specify the Server Url and Port in your Client application, i.e for the following scenario:
Server:
http://localhost:8000/Client:
http://localhost:22914/Client Application:
Documented at the bottom of the SignalR Client Hubs Wiki on Github