Hello im trying to migrate a project from .net core to mvc and i have some issues about signalr.
This work on new mvc project.
Reference the auto-generated proxy for the hub.
var chat = $.connection.chatHub;
// Start the connection.
$.connection.hub.start().done(function () {
alert("done");
});
But this one which is from the old(.net core) project doesnt work. Error is: Uncaught ReferenceError: signalR is not defined
var connection = new signalR.HubConnectionBuilder().withUrl("/chatHub").build();
connection.start().then(function () {
console.log('SignalR Started...');
viewModel.roomList();
viewModel.userList();
setTimeout(function () {
if (viewModel.chatRooms().length > 0) {
viewModel.joinRoom(viewModel.chatRooms()[0]);
}
}, 250);
}).catch(function (err) {
return console.error("!!!!!" + err);
});
browser/signalr.js the first one define signalR but this time the error is: Error: Failed to complete negotiation with the server: Error
My main problem was in my constructor method. I could not trigger server side methods. My old project want initialize variables and there was no try catch block. So i deleted constructor method. Then it worked.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.