SignalR: Error loading hubs

daniel picture daniel · Nov 22, 2013 · Viewed 21.9k times · Source

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>

Answer

Rob Lyndon picture Rob Lyndon · Nov 22, 2013

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>