像我的问题有很多问题,但我没有任何有效的解决方案 .

我在我的应用程序中使用AngularJS和WebApi2 .

这是调用初始API的JS代码 .

(function (module) {
var baseUrl= "http://localhost:85";
module.constant('Config', baseUrl);
module.service('identities', ['$http', function ($http) {
    var uri = baseUrl+ '/api/controller/GetRole';

    var identities = {};
    identities.get = function () {
        var temp = $http.get(uri);
        console.log(temp, "identities");
        return temp;
    }
    return identities;
}]);

此函数调用Web API控制器中的GetRole方法以检索用户角色 . 此方法的输出是带有用户详细信息的JSON .

我已将服务器上的应用程序部署到端口85.当我运行应用程序时,它在Chrome中引发错误:

net :: ERR_CONNECTION_REFUSED

在IE 11中:

XMLHttpRequest:网络错误0x2efd,由于错误00002efd无法完成操作

IIS中没有为此请求创建日志 .

使用fiddler我在Raw中得到了这个,状态代码为502 . 与“localhost”的连接失败 .

错误:ConnectionRefused(0x274d) . System.Net.Sockets.SocketException无法 Build 连接,因为目标计算机主动拒绝它127.0.0.1:85 .

我也试过通过禁用chrome中的CORS但没有运气 . 如果我在角度JS代码中使用服务器的IP地址而不是localhost作为baseUrl那么它工作正常 . 为什么它不能与localhost一起使用?

我正在进行GET调用,而对我来说错误是00002efd而不是00002ef3 .