角度控制器
$scope.notification = $.connection.notificationsHub;
$scope.SendNotification = function (schoolId) {
$http({
url: "/Notifications/InsertNotification?SchoolId=" + schoolId+"&Notification="+$scope.Notification,
method: "GET"
}).then(function (res) {
console.log(res);
notification.client.sendNotification = function () {
getAllNotifications();
}
$.connection.hub.start().done(function () {
getAllNotifications();
}).fail(function (e) {
console.log(e);
alert(e);
})
function getAllNotifications() {
$http({
url: "/Notifications/Notifications?SchoolId=" + schoolId,
method: "GET"
}).then(function (res) {
console.log(res);
});
}
});
}
C# 代码(中心类(
public void Send()
{
IHubContext context = GlobalHost.ConnectionManager.GetHubContext<NotificationsHub>();
context.Clients.All.SendNotification();
}
我尝试在owin启动类中添加map,所有脚本都放置在正确的位置,我尝试了很多解决方案,但它不起作用,我需要帮助:D
我找到了一个解决方案,说从全局.cs文件中注释或删除捆绑寄存器,并且似乎 signalR 的文件与 bundleconfig.cs 文件中的其他.js文件冲突,它解决了