asp.net - Client can't connect to SignalR Hub (CORS does not work) -
my startup.cs in server (implementing cross-domain requests using owin.usecors):
public void configuration(iappbuilder app) { app.map("/signalr", map => { // setup cors middleware run before signalr. // default allow origins. can // configure set of origins and/or http verbs // providing cors options different policy. map.usecors(corsoptions.allowall); var hubconfiguration = new hubconfiguration { // can enable jsonp uncommenting line below. // enablejsonp = true }; // run signalr pipeline. we're not using mapsignalr // since branch runs under "/signalr" // path. map.runsignalr(hubconfiguration); }); }
my client (console project):
static void main(string[] args) { ihubproxy _hub; string url = @"http://111.111.111.111:13098/signalr/hubs"; var connection = new hubconnection(url, querystringdata); _hub = connection.createhubproxy("testhub"); connection.start().wait(); _hub.on("broadcast", x => console.writeline(x)); }
only when run client (console.exe) @ server (signalr project hosted in iis), can connect hub.
if run client @ computer, it not capable of getting connected.
why?
input http://111.111.111.111:13098/signalr/hubs @ chrome:
can enable jsonp , see?
var hubconfiguration = new hubconfiguration { enablejsonp = true };
Comments
Post a Comment