我将SignalR添加到现有的ASP.Net 4Web Forms应用程序中。创建了一个名为Hubs的新文件夹并添加了一个Hub,如下所示:
[HubName("UpdatesHub")]
public class UpdatesHub : Hub
{
public void DownloadUpdates()
{
// Code Removed
}
}在Application_Start中添加了RouteTable.Routes.MapHubs();,并在页面中添加了以下内容:
<script src="/Scripts/jquery-1.9.1.js"></script>
<script src="/Scripts/jquery.signalR-1.0.1.js"></script>
<script src="/signalr/hubs"></script>
<script type="text/javascript">
$(function () {
// Declare a proxy to reference the hub.
var upd = $.connection.UpdatesHub;
// Code Removed
// Start the connection.
$.connection.hub.start().done(function () {
$('#btnDownload').click(function () {
upd.server.DownloadUpdates();
});
});
});
</script>但每当我单击按钮时,我就会得到“未捕获方法: Object # has no TypeError 'DownloadUpdates'”。我试过通过NuGet删除和读取signalr,但似乎不能让它工作,帮帮忙!
发布于 2013-04-08 18:58:27
SignalR camelCases the method names on the server.尝试检查downloadUpdates()是否存在。
https://stackoverflow.com/questions/15877242
复制相似问题