Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SignalR: $.connection is undefined

Tags:

I'm using Visual Studio 2012 Ultimate RC, SignalR 0.5.1 and Jquery 1.7.2 in an MVC4 application.

I have looked at: MVC4 SignalR "signalr/hubs" 501 Not Implemented Error

But it does not affect my issue (I am using IIS Express to debug).

When I try to utilize SignalR the $.connection variable is undefined. My server side code:

[HubName("tenantHub")]
public class TenantHub : Hub
{
    ...
    void TenantChange(CrudAction action, Tenant tenant)
    {
        Clients.eventOccurred(action.ToString(), tenant);
    }
}

Client side:

$(function() { var test = $.connection.tenantHub; });

Client side SignalR/hubs is being referenced and I can see the JS code, it does not throw any errors. But referencing $.connection throws a Uncaught TypeError: Cannot read property 'tenantHub' of undefined. Also tried to do the default chat example, it gives the same error. Is SignalR unsupported when utilized in VS2012 or am I just being stupid?

like image 482
Bas Avatar asked Jun 24 '12 17:06

Bas


1 Answers

Try removing the BundleConfig.RegisterBundles(BundleTable.Bundles); from Global.asax.cs, and see if that helps?

like image 151
user1502389 Avatar answered Oct 16 '22 23:10

user1502389