javascript - 调试时出现 404 Not Found,但 URL 在浏览器中有效

标签 javascript angularjs visual-studio-2015 windows-10 iis-10

我刚刚从 Win 7 笔记本电脑迁移到 Win 10。在 Win 10 上调试 Web 应用程序时,出现 404 Not Found 错误。但是,如果我将 URL 粘贴到浏览器中,它就会起作用。 Win 10 或 IIS 10 是否有一些奇怪的地方需要更改才能使其正常工作?这在 Win 7 上的 VS 中调试时效果很好。

这是 JavaScript:

var config = {
    url: rootWebApiUrl + '/api/admin/getAdUserName',
    method: 'GET'
};

$http(config)
    .then(function (response) {
        $scope.userName = response.data;
    }, function (response) {
        console.log('err: ', response);
});

这是错误:

enter image description here

以及正在使用的 URL:

enter image description here

如果我将该 URL 粘贴到 IE 中,它就会起作用并且我会获取数据。我错过了什么?

最佳答案

127.0.0.1 替换为 rootWebApiUrl。我相信服务器在调试时不知道地址,通过请求回溯地址。 Windows 10 和新服务器更愿意使用 IPv6,并且只有 localhost 会影响这一点。现在,为什么正常模式与 Debug模式之间存在这种差异,对我来说并不是很自信。

关于javascript - 调试时出现 404 Not Found,但 URL 在浏览器中有效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39596600/

相关文章:

javascript - AngularJS 与 jQuery DataTables 间歇性工作

html - Angularjs如何计算两张表的总和值?

visual-studio - Visual Studio 2015丢失设置

javascript - 流程图和javascript

javascript - Angular 捕获所有浏览器的后退按钮事件

javascript - 手动将 dirty 设置为字段不会修改 css 类 angularJS?

c++ - VC++ 可再发行版 2012 或 2013 或 2015?

c++ - Visual Studio 2015 “Apply Code Changes” 被禁用

javascript - 如何更改 TinyMce 编辑器中的默认字体调色板?

javascript - 如何仅在 jquery on() 函数不存在时设置它?