How to use cross-domain connections (CORS - Access Control Allow Origin) with SignalR

前端 未结 6 1052
有刺的猬
有刺的猬 2020-12-05 03:08

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

6条回答
  •  时光说笑
    2020-12-05 03:24

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

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

      RouteTable.Routes.MapHubs(new HubConfiguration()
      {
        EnableCrossDomain = true
      });
      

提交回复
热议问题