codezoo codezoo - 1 year ago 166
ASP.NET (C#) Question

SignalR: Cross-domain connections (CORS - Access Control Allow Origin) issues

Using persistent connections and an ASP.Net Javascript client, I am trying to connect to a sub -domain not the same as the one the page was served from.

ASP.Net Page from webserver wants to connect to SignalR at The same code works fine when connecting within the same sub-domain.

I found another post where cross-domain connections were enabled with: = true;
but this did not work for me.

How can I connect to SignalR in a second sub-domain using persistent connection and a JavaScript client?

Answer Source

You need to do one of the following to make it work:

  • Set up $.connection.hub.url = '';, pointing to your subdomain.
  • Enable cross domain on the server:

    RouteTable.Routes.MapHubs(new HubConfiguration()
      EnableCrossDomain = true
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download