在对象VAR聊天未定义错误= $ .connection.chat;同时使用SignalR [英] Object undefined error at var chat = $.connection.chat; while using SignalR
问题描述
我尝试安装SignalR库创建一个示例聊天应用程序。我相信我已经遵循了文档给出的所有步骤。我不知道这可能是一个失败的原因。
I tried installing SignalR library to create a sample chat application. I believe I have followed all steps given in documentation. I am not sure what could be a reason of failing.
当它创建一个聊天对象,它是失败的。我使用VS2010和我下载使用SignalR VS2010包下载工具。
It is failing when it creates a chat object. I am using VS2010 and I downloaded SignalR using VS2010 package download utility.
有没有人有一个问题与此?
Is anyone had an issue with this?
谢谢,
萨米尔
Thanks, Samir
感谢Hurricanepkt帮我。
Thanks Hurricanepkt for helping me out.
是的,我没有通过的NuGet得到所有signalR,使用VS2010添加库包对话框。我正在对象未定义的错误,在VAR聊天= $ .connection.chat;
Yes, I did get all signalR via nuget, using VS2010 'Add Library Package' dialog box. I was getting object undefined error, at var chat = $.connection.chat;
我只是做了它的工作,但它是ASP.NET Web应用程序项目。我不能使它与ASP.NET网站项目。我不知道为什么。
I just made it work but it was ASP.NET Web Application Project. I could not make it work with ASP.NET Website project. I don't know why.
我相信它是由于网站项目与在ASP.NET Web应用程序项目固定的DLL动态的dll创建。
I believe it due to dynamic dll creation in Website Project vs. fixed dll in ASP.NET Web Application Project.
你有没有遇到过这样的问题?
Have you encounter such issue?
推荐答案
什么是你的集线器的名字吗?如果你已经改成了比聊天以外的东西那么它将无法正常工作。我有同样的问题,因为我改变了我的为:
What's the name of your hub? If you've changed it to something other than "Chat" then it won't work. I had the same issue because I changed mine to:
public class ChatHub : Hub
{
public void Send(string message)
{
Clients.addMessage(message);
}
}
在JavaScript这样的:
Within the Javascript this:
var chat = $.connection.chat;
需要改变,以
var chat = $.connection.chatHub;
这篇关于在对象VAR聊天未定义错误= $ .connection.chat;同时使用SignalR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!