Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
674 views
in Technique[技术] by (71.8m points)

visual studio 2012 - SignalR: $.connection is undefined

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...