0
當我有兩個域名的網站:問題創造跨域SignalR連接
- a.com
- b.com
b.com承載SignalR中心,和。 com嘗試創建與b.com的連接。
客戶端JS:
var connection = $.hubConnection('http://b.com/');
var notificationHubProxy = connection.createHubProxy('notificationHub');
$.connection.hub.logging = true;
notificationHubProxy.client.resultReceived = function (result) {
console.log(result);object.
}
服務器eventHub:
public class NotificationHub : Hub
{
public void Hello()
{
Clients.All.hello();
}
public string Echo()
{
return "Notification hub is running normally";
}
}
但我總是在客戶端頁面上看到以下錯誤:
SCRIPT5007:無法設置屬性「resultReceived '未定義或 空引用。
當我檢查'notificationHubProxy。 客戶端'未定義。
哪裏出錯?
是的,這正是根本原因。 – smwikipedia