Short answer: Yes - As the SinalR documentation illustrates.
The first step is to create a cross-domain on your server. Now you can activate calls from all domains or only from the specified ones. ( See this publication on this subject )
public void Configuration(IAppBuilder app)
{
var policy = new CorsPolicy()
{
AllowAnyHeader = true,
AllowAnyMethod = true,
SupportsCredentials = true
};
policy.Origins.Add("domain");
app.UseCors(new CorsOptions
{
PolicyProvider = new CorsPolicyProvider
{
PolicyResolver = context => Task.FromResult(policy)
}
});
app.MapSignalR();
}
The next step is to configure the client to connect to a specific domain.
(. ), TestHub
var hub = $.connection.testHub;
$.connection.hub.start();
, , URL-, SignalR . ( ).
, , , , .
`var hub = $.connection.testHub;
$.connection.hub.url = "http://yourdomain/signalr" - with the default routing
$.connection.hub.start();`
. . !