SignalR 1.0.1跨域请求(CORS)与铬 [英] SignalR 1.0.1 Cross-domain request (CORS) with Chrome

查看:697
本文介绍了SignalR 1.0.1跨域请求(CORS)与铬的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想实现跨域与SignalR 1.0.1用浏览器(版本25.0.1364.172)调用。由于我有我的UI在一个主机(本地主机:16881),并在另一台主机服务(本地主机:16901)。

I am trying to implement the Cross-domain calls with SignalR 1.0.1 with Chrome (Ver 25.0.1364.172). As I have my UI in one host (localhost:16881) and the 'service' in another host (localhost:16901).

我已经一切就绪为题<一中href=\"http://stackoverflow.com/questions/9984534/signalr-cross-domain-connections-cors-access-control-allow-origin-issues\">SignalR:跨域连接(CORS - 访问控制允许产地)问题

 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.

我也有HubConfiguration设置为我的路由映射在Global.asax中的SignalR 1.0.1

I also have the HubConfiguration set up for my route mapping in global.asax for SignalR 1.0.1

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

一切看起来都在IE10和FF22的罚款。但是在Chrome中,它给我的时候SignalR试图做握手的erorr。

Everything looks fine in IE10 and FF22. However in Chrome, it gives me an erorr when SignalR trying to do the handshake.

XMLHttpRequest cannot load http://localhost:16901/signalr/negotiate?_=1363560032589. Origin http://localhost:16881 is not allowed by Access-Control-Allow-Origin. 

我知道我可以把它用--disable-Web的安全启动它与Chrome的工作,但它并没有真正适合我的要求。请帮助!

I know I can get it works with Chrome by launching it with --disable-web-security, but it doesn't really fit my requirement. Please help!

推荐答案

下面是你需要做的:


  1. 删除jQuery.support.cors = TRUE

  2. 删除&LT;添加名称=访问控制允许来源VALUE =HTTP://本地主机:16881/&GT;

  1. Remove jQuery.support.cors = true
  2. Remove <add name="Access-Control-Allow-Origin" value="http://localhost:16881" />

然后,它应该工作正常。

Then it should work fine.

这篇关于SignalR 1.0.1跨域请求(CORS)与铬的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆