私はAngler 2とASP.NET CoreをSignalRで操作しています。Cors with Signalr
私は以下のようにエラーがあります:
のXMLHttpRequestが http://localhost:55916/signalr//signalr/negotiate?clientProtocol=1.5&connectionData=%5B%7B%22name%22%3A%22event%22%7D%5D&_=1486394845411をロードすることはできません。 要求の認証モードが 'include'の場合、レスポンス の 'Access-Control-Allow-Origin'ヘッダーの値はワイルドカード '*'であってはなりません。したがって、オリジン ' http://localhost:8080'は許可されません。 XMLHttpRequestによって開始された要求の信任状モードは、withCredentials属性によって制御されます。
私のアプリの設定があります:
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
var signingKey = new SymmetricSecurityKey(Encoding.ASCII.GetBytes(Configuration["data:secretKey"]));
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
app.UseCors(config =>
config.AllowAnyHeader().AllowAnyMethod().AllowAnyOrigin());
app.UseWebSockets();
app.UseSignalR("/signalr");
app.UseMvc();
}
私も角度2 SignalRサービス魔女サーバイベントregiestering
constructor(){
//setups...
this.connection = $.hubConnection(this.baseUrl + 'signalr/');
this.proxy = this.connection.createHubProxy(this.proxyName);
this.registerOnServerEvents();
this.startConnection();
}
あります
private registerOnServerEvents(): void {
this.proxy.on('FoodAdded', (data: any) => {
debugger;
this.foodchanged.emit(data);
});
this.proxy.on('FoodDeleted', (data: any) => {
debugger;
this.foodchanged.emit('this could be data');
});
this.proxy.on('FoodUpdated', (data: any) => {
debugger;
this.foodchanged.emit('this could be data');
});
this.proxy.on('SendMessage', (data: ChatMessage) => {
debugger;
console.log('received in SignalRService: ' + JSON.stringify(data));
this.messageReceived.emit(data);
});
this.proxy.on('newCpuValue', (data: number) => {
debugger;
this.newCpuValue.emit(data);
});
}
エラーがで始まるをかわいい。
あなたは、この問題を解決しましたか?私もそれと戦っている:( – wh1sp3r
ああ私はそれは私に数分を与える投稿しました:) – miechooy