【发布时间】:2020-01-09 01:15:46
【问题描述】:
我已经在测试服务器上部署了(使用端口 9021 和站点名称 Production)Angularjs Web API 应用程序,当我点击 URL 时
http://localhost:9021/api/Item/GeAreas?P_Id=US99
在测试服务器上,我成功获得了来自 Web API 的响应。
这是api调用的代码:
function getAreas(P_Id) {
$http({
method: 'GET',
url: 'http://ps-test.aars/api/Item/GetAreas',
// url: 'http://ps-test.aars/Production/api/Item/GetAreas', // error msg: the server responded with a status of 404 (Not Found) /Production/api/Item/GetAreas?P_Id=US99
params: { P_Id: P_Id },
headers: { 'Content-Type': 'application/json; charset=utf-8', 'dataType': 'json' }
}).then(function successCallback(response) {
$scope.Areas = response.data;
}, function errorCallback(response) { }
});
}
web.config:
<handlers>
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
当我点击网址时:
http://ps-test.aars/Production/Summary.html?P_Id=US99
在我的本地系统上,我收到一个错误:
加载资源失败:服务器响应状态为 404(未找到)/api/Item/GetAreas?P_Id=US99
不确定是什么问题。
【问题讨论】:
标签: angularjs api asp.net-web-api http-status-code-404 asp.net-web-api-routing