Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SignalR: Error loading hubs

Signalr doesn't load my hubs:

SignalR: Error loading hubs. Ensure your hubs reference is correct, e.g. <script src='/signalr/js'></script>. 

I am calling app.MapSignalR(); in startup configuration.

I added to my cshtml:

<script src="~/Scripts/jquery-1.9.1.js"></script>
<script src="~/Scripts/jquery.signalR-2.0.0.js"></script>
<script src="~/signalr/hubs" type="text/javascript"></script>

<script>

    $(document).ready(function () {
        window.hubReady = $.connection.hub.start();
    });

</script>
like image 957
daniel Avatar asked Nov 22 '13 12:11

daniel


3 Answers

Make sure your startup class has this attribute:

[assembly: OwinStartup(typeof(MyStartupClass))]

You can define your Owin startup class in your web.config as well:

<appSettings>  
    <add key="owin:appStartup" value="MyNamespace.MyStartupClass" />
</appSettings>
like image 105
Rob Lyndon Avatar answered Oct 07 '22 23:10

Rob Lyndon


Visit your site, ex http://localhost/signalr/hubs, and see if you can get a better error description there. My problem was that I had a generic method in my hub.

public void Update<T>(T objectToUpdate) where T : class
like image 40
Ogglas Avatar answered Oct 07 '22 23:10

Ogglas


Also make sure to add in your Startup class:

app.MapSignalR();

Solved my issue

like image 3
JustLearning Avatar answered Oct 07 '22 22:10

JustLearning