我正在尝试使用SignalR 1.0.1与Chrome(Ver 25.0.1364.172)实现跨域调用.因为我在一个主机(localhost:16881)中有我的UI,在另一个主机(localhost:16901)中有’service’.
我有一切就绪,如主题How to use cross-domain connections (CORS – Access Control Allow Origin) with SignalR
add jQuery.support.cors = true; before opening a connection set up $.connection.hub.url = 'http://localhost:16901/signalr';,pointing to your subdomain allow cross-domain requests on server side,by adding the following header description: <add name="Access-Control-Allow-Origin" value="http://localhost:16881" /> inside system.WebServer/httpProtocol/customHeaders section in Web.config file.
我还为在Signal. 1.0的global.asax中的路由映射设置了HubConfiguration
RouteTable.Routes.MapHubs(new HubConfiguration() { EnableCrossDomain = true });
在IE10和FF22中一切都很好看.但是在Chrome中,当SignalR尝试进行握手时,它给了我一个惊喜.
XMLHttpRequest cannot load http://localhost:16901/signalr/negotiate?_=1363560032589. Origin http://localhost:16881 is not allowed by Access-Control-Allow-Origin.
我知道我可以通过使用–disable-web-security启动它来使用它,但它并不真正符合我的要求.请帮忙!