c# - $.connection.Hub undefine -
using signal r in frame work 4.0. when calling hub class(testhub) display undefine. jquery code bellow
<head runat="server"> <title></title> <script src='<%: resolveclienturl("scripts/jquery-1.6.4.js") %>'></script> <script src='<%: resolveclienturl("scripts/jquery-1.6.4.min.js") %>'></script> <script src='<%: resolveclienturl("scripts/jquery.signalr-1.0.0-rc1.js") %>'></script> <script src='<%: resolveclienturl("scripts/jquery.signalr-1.0.0-rc1.min.js") %>'></script> <script src='<%: resolveclienturl("signalr/hubs") %>'></script> </head> <body> <form id="form1" runat="server"> var data = $.connection.tenanthub; $.connection.hub.logging = true; console.log(data); //undefine </script> </form>
i have global.asax not through error on
void application_start(object sender, eventargs e) { // code runs on application startup routetable.routes.maphubs(); }
i have hub class within hubs folder bellow.
[hubname("tenanthub")] public class testhub:hub { public void send(string message) { clients.all.addmessage(message); } }
package bellow
<?xml version="1.0" encoding="utf-8"?> <packages> <package id="jquery" version="1.6.4" targetframework="net40" /> <package id="microsoft.aspnet.signalr" version="1.0.0-rc1" targetframework="net40" /> <package id="microsoft.aspnet.signalr.core" version="1.0.0-rc1" targetframework="net40" /> <package id="microsoft.aspnet.signalr.js" version="1.0.0-rc1" targetframework="net40" /> <package id="microsoft.aspnet.signalr.owin" version="1.0.0-rc1" targetframework="net40" /> <package id="microsoft.aspnet.signalr.systemweb" version="1.0.0-rc1" targetframework="net40" /> <package id="microsoft.owin.host.systemweb" version="1.0-rc1" targetframework="net40" /> <package id="microsoft.web.infrastructure" version="1.0.0.0" targetframework="net40" /> <package id="newtonsoft.json" version="4.5.4" targetframework="net40" /> <package id="owin" version="1.0" targetframework="net40" /> </packages>
the last compatible signalr version .net framework 4.0 1.2.2 :
can try update signalr version opening nuget package manager console , typing :
install-package microsoft.aspnet.signalr.client -version 1.2.2 install-package microsoft.aspnet.signalr -version 1.2.2
a full chat example based on jquery 1.6.4 fwk 4 , signalr 1 : http://www.bluelemoncode.com/2013/02/default.aspx
moreover don't resolve twice js scripts (keep minified or uncompressed depending on environment):
<script src='<%: resolveclienturl("scripts/jquery-1.6.4.min.js") %>'></script> <script src='<%: resolveclienturl("scripts/jquery.signalr-1.0.0-rc1.min.js") %>'></script>
Comments
Post a Comment