This is my chat javascript
"use strict";
var connection = new signalR.HubConnectionBuilder().withUrl("/chathub").build();
connection.on("ReceiveMessage", function (message) {
var msg = message.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
var encodedMsg = msg;
var li = document.createElement("li");
li.textContent = encodedMsg;
document.getElementById("Messages").appendChild(li);
});
connection.start().catch(function (err) {
return console.error(err.toString());
});
document.getElementById("Send").addEventListener("click", function (event) {
var message = document.getElementById("Message").value;
connection.invoke("SendMessage", message).catch(function (err) {
return console.error(err.toString());
});
event.preventDefault();
});
This is the error I get when I run the page with my chat input:
Uncaught ReferenceError: signalR is not defined at chat.js:3
line 3 in chat.js
is:
var connection = new signalR.HubConnectionBuilder().withUrl("/chathub").build();
I downloaded the SignalR
client library from Visual Studio Add Client Side Library. What I have now is a file called jquery.signalR.js
and it is the ASP.NET SignalR Javascript Library 2.4.0.
However, this error doesn't go away and I am unable to proceed for some reason.