SignalR is not loaded. Please ensure jquery.sigalR-x.js is referenced before ~/signalr/js

17,716

Solution 1

A JavaScript client requires references to jQuery and the SignalR core JavaScript file. The jQuery version must be 1.6.4 or major later versions, such as 1.7.2, 1.8.2, or 1.9.1. If you decide to use the generated proxy, you also need a reference to the SignalR generated proxy JavaScript file. The following example shows what the references might look like in an HTML page that uses the generated proxy.

<script src="Scripts/jquery-1.10.2.min.js"></script>
<script src="Scripts/jquery.signalR-2.1.0.min.js"></script>
<script src="signalr/hubs"></script>

These references must be included in this order: jQuery first, SignalR core after that, and SignalR proxies last.
- from ASP.NET SignalR Hubs API Guide - JavaScript Client

Your problem is that, somehow, the order in what you are loading the references is wrong.

Solution 2

100% working if you want to debug on locally. how to debug SingalR locally?

Answer : on cshtml page drag and drop js jquery.signalR-2.4.2.js in this way.Don't use min.js for debug and use this version for locally debug mode.

<script src="~/Scripts/jquery.signalR-2.4.2.js"></script>
<script src="@Url.Content("http://localhost:57305/signalr/hubs")"></script>

Download all supported Signal R js from cdn. https://www.cdnpkg.com/signalr.js/file/jquery.signalR.min.js/

Share:
17,716
RGS
Author by

RGS

Updated on June 26, 2022

Comments

  • RGS
    RGS almost 2 years

    I have referenced below two libraries dynamically in my page. When I browse my application below mentioned error did not come in Chrome browser. But in Internet Explorer the error occurs.

    var signalRLibrary = document.createElement('script');
    signalRLibrary.type = "text/javascript";
    signalRLibrary.src = 'jquery.signalR-2.1.2.min.js';
    document.getElementsByTagName('head')[0].appendChild(signalRLibrary);
    
    var signlaRHub = document.createElement('script');
    signlaRHub.type = "text/javascript";
    signlaRHub.src = "~/signalr/hubs";
    document.getElementsByTagName('head')[0].appendChild(signlaRHub);
    

    During page load I got below error as SignalR is not loaded. Please ensure jquery.signalR-x.js is referenced before ~/signalr/js.

    if (typeof ($.signalR) !== "function") {
            throw new Error("SignalR: SignalR is not loaded. Please ensure jquery.signalR-x.js is referenced before ~/signalr/js.");
    }
    

    enter image description here enter image description here