Connect SignalR in a hub that is inside a WCF service

hi is currently using SignalR in my WebApplication. I have a problem connecting signalR to my hub, this is my connection code which is in the main application.

 var chat = $.connection.sampleHub;

      

while this is my hub

using Microsoft.AspNet.SignalR;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace SampleService
{
    public class SampleHub : Hub
    {
        public void Send(string name, string message)
        {
            //Update All the Clients Connected
            Clients.All.addNewMessageToPage(name, message);
        }
    }
}

      

this is located in a separate WCF service, they are on the same solution but in a different project, I think its connection is preventing my client from connecting to a WCF service that implements the SignalR library?

+3


source to share


1 answer


Of course you can, they live under different hosts, so you'll have to adapt the Urls to point to the correct location. You will need to use an absolute address on the server where necessary (for example, when linking to dynamic hubs) and also handle cross-domain requests. You can check here and here for more details here .



+3


source







All Articles