Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SignalR across domains

I'm trying to get a basic sample across domains working, but I just cannot get it to work. According to someone here https://github.com/SignalR/SignalR/issues/6 he got it to work by adding a Access-Control-Allow-Origin header.

Basically, I've added a hub to an mvc 3 application, added the above header in the web.config, and created a page to send a message. This setup works fine. Next, I've created a different web application using the same client javascript on a page, but setting the url to a different server using:

$.connection.hub.url = 'http://www.myserver.com/signalr';

As soon as I use a remote url it stops working.

How can I get SignalR to work across domains?

Update: Some added information, the above approach works for chrome and firefox, but IE9 is not liking it...

like image 373
Rob Tillie Avatar asked Mar 17 '12 15:03

Rob Tillie


1 Answers

I got it working using a simple test project and Internet Explorer 9, but it wasn't easy and first I was hung on the same problems you described. I think you are almost there and you are only missing the following line in your JavaScript:

jQuery.support.cors = true;

which tells jQuery to do cross domain calls. Seems simple, but was really hard to find ;-)

I explained all the steps I did in a blog post since I didn't find any existing information on this topic so far.

Tell me if there are any more problems. I have a working test project running in Internet Explorer 9 which I can send you.

like image 97
aKzenT Avatar answered Nov 13 '22 11:11

aKzenT