1
我正在使用signalr的网站上工作,它工作正常,当我在本地机器上测试它时,但是当ai远程尝试时,我无法浏览mvc,而当我尝试发送请求时签署它只是坐在那里等待。SignalR不适用于远程连接
这里是我的javascript代码(我使用angularjs但所有的代码工作正常!):
function FixturesListController($scope,$q) {
$scope.fixtures = [''];
var stringListHub = $.connection.stringListHub,
model = {
Items: []
};
$.connection.hub.url = "http://192.168.1.2:8001/signalr";
stringListHub.client.updateModel = function(newName) {
if (newName.Items != null) {
$scope.$apply(function() {
$scope.fixtures.length = 0;
$(newName.Items).each(function(index, value) {
$scope.fixtures.push(value);
});
});
}
}
$.connection.hub.start({ xdomain: true }).done(function() {
var fixtures = stringListHub.server.test().done(function (item) {
$scope.$apply(function() {
if (item.Items != null) {
$scope.fixtures.length = 0;
$(item.Items).each(function(index, value) {
$scope.fixtures.push(value);
});
}
});
});
});
$scope.AddFixture = function() {
$scope.fixtures.push($scope.newName);
stringListHub.server.updateModel({
Items: $scope.fixtures
});
};
}
这里是signalr枢纽:
public class StringListHub : Hub
{
private static StringList _list = new StringList();
public void UpdateModel(StringList model)
{
_list = model;
_list.LastUpdatedBy = Context.ConnectionId;
// Update the shape model within our broadcaster
Clients.AllExcept(_list.LastUpdatedBy).updateModel(_list);
}
public StringList Test()
{
return _list;
}
}
而且我添加到了我的网络.config
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
</modules>
</system.webServer>
“无法浏览MVC”,这是什么意思?你是否收到任何错误信息? – Steve
您是否使用过Fiddler或Firebug之类的东西来查看是否有响应错误代码被发送回来或出现javacript错误? – Steve
是的,尝试了所有的和cannont浏览mvc我的意思是它只是坐在那里加载和没有任何反应 –