在localhost中,它工作正常,但是当我将其发布到服务器时,它向我发送以下错误: 无法加载资源:服务器的响应状态为500。
已启用Iss的服务WebSockets和Framework 4.5
有什么想法吗?
我的代码是:
<script src="Scripts/jquery-1.6.4.min.js"></script>
<script src="Scripts/jquery.signalR-2.3.0.min.js"></script>
<script src="signalR/hubs"></script>
<script type="text/javascript">
$(function () {
var job = $.connection.myHub;
job.client.displayStatus = function () {
getData();
};
$.connection.hub.start();
getData();
});
function getData() {
var $tbl = $('#tbl');
$.ajax({
url: 'index.aspx/GetData',
contentType: "application/json; charset = utf-8",
dataType: "json",
type: "POST",
success: function (data) {
//debugger;
if (data.d.length > 0) {
var newdata = data.d;
$tbl.empty();
$tbl.append('<tr><th>ID</th><th>Name</th><th>Price</th><th>Qty</th></tr>');
var rows = [];
for (var i = 0; i < newdata.length; i++) {
rows.push(' <tr><td>' + newdata[i].id + '</td><td>' + newdata[i].Name + '</td><td>' + newdata[i].PricDecimal + '</td><td>' + newdata[i].QuantDecimal + '</td></tr>');
}
$tbl.append(rows.join(''));
}
}
});
}
</script>
我的班级中心是:
public class MyHub: Hub
{
public static void Show()
{
IHubContext context = GlobalHost.ConnectionManager.GetHubContext<MyHub>();
context.Clients.All.displayStatus();
}
}