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.
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
Thanks Hurricanepkt for helping me out.
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;
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.
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);
}
}
Within the Javascript this:
var chat = $.connection.chat;
needed to change to
var chat = $.connection.chatHub;
I was frustrated because of the same problem. It works in Web Project but in Web site it's not. So I checked the script file which is dynamically created.
Left: Web Project - Right: Web Site (http://i.imgur.com/X1XrT.jpg)
As you can see in web site it is not creating "chat" object so it says undefined. After reading your sentences about dynamic dll creation, I put my code behind file in a seperate .cs file and I put that cs file in App_Code folder. I tried and bam, it worked. Checked the dynamic script file:
(http://i.imgur.com/CSInO.jpg)
I don't know much about the technical issue in here, but putting your code in a seperete Class file which is located in App_Code folder resolves the issue.. Have a nice day
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With