Angularjs $http.post发布大文本时返回404
我有一个AngularJS应用程序,可以与ASP.NET Web API对话。在我的一个表单中,当我发布少量文本时,它工作得非常好。但是当我发布大量文本时,我得到了404错误 我已将Web API的请求过滤设置更新为:Angularjs $http.post发布大文本时返回404,angularjs,iis,asp.net-web-api,Angularjs,Iis,Asp.net Web Api,我有一个AngularJS应用程序,可以与ASP.NET Web API对话。在我的一个表单中,当我发布少量文本时,它工作得非常好。但是当我发布大量文本时,我得到了404错误 我已将Web API的请求过滤设置更新为: <system.webServer> <security> <requestFiltering> <requestLimits maxAllowedContentLength="10485760" />
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="10485760" />
</requestFiltering>
</security>
</system.webServer>
<configuration>
<system.web>
<httpRuntime maxRequestLength="51200" timeout="3600" />
</system.web>
</configuration>
调用Web API的Javascript方法:
function updateNotification(notification) {
return $http.post(appConfig.apiUrl + '/notifications/',
JSON.stringify(notification))
.then(updateNotificationComplete)
.catch(function (message) {
exception.catcher('XHR Failed for updateNotification')
(message);
});
function updateNotificationComplete(data, status, headers, config) {
return data.data;
}
}
Javascript调用:
dataservice.updateNotification(vm.notification).then(function (data) {
if (data !== "error") {
if (!vm.notification.Id || vm.notification.Id <= 0)
{
vm.notification.Id = data;
vm.notificationId = data;
}
logger.success("Save successful");
}
});
dataservice.updateNotification(vm.notification)。然后(函数(数据){
如果(数据!=“错误”){
如果请考虑将函数用<代码> $http.PoST <代码>在您的前端发布,以及接收数据的WebAPI服务。您的函数和函数调用在哪里?JavaScript和Web API方法增加了-谢谢!不幸的是,这个链接指向了我尝试应用ABO的解决方案。但是,我注意到$http.put工作得非常好,所以我现在使用它。
dataservice.updateNotification(vm.notification).then(function (data) {
if (data !== "error") {
if (!vm.notification.Id || vm.notification.Id <= 0)
{
vm.notification.Id = data;
vm.notificationId = data;
}
logger.success("Save successful");
}
});