我面临着奇怪的问题,虽然花了很多时间但仍然无法解决它
之前的put请求工作正常我遇到了
的问题无法加载资源:服务器响应状态为404(未找到) fontawesome-webfont.woff2?v = 4.3.0
我通过添加
解决了这个问题<staticContent>
<remove fileExtension=".woff" />
<mimeMap fileExtension=".woff" mimeType="application/font-woff" />
<remove fileExtension=".woff2" />
<mimeMap fileExtension=".woff2" mimeType="font/x-woff" />
</staticContent>
虽然它解决了这个问题,但是我的put方法在抓了我的头之后没有工作我知道它不是我的DTO的绑定模型,虽然ModelState.IsValid == true但是我的DTO模型是null并且这只发生在put请求所有其他请求工作正常,如get,getall,delete,post,这只发生在chrome中。在Firefox中,put请求工作正常。
我无法理解ModelState是否为真,那么为什么chrome不会将数据绑定到我的DTO以下是chrome和Firefox的标题请求
铬
PUT /api/AddressTypeAPI/1 HTTP/1.1
Host: localhost:xxxx
Connection: keep-alive
Content-Length: 194
Accept: application/json, text/plain, */*
Origin: http://localhost:xxxx
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36
Authorization: Bearer xxxx
Content-Type: application/json;charset=UTF-8
Referer: http://localhost:xxxx/AddressType/Index
Accept-Encoding: gzip, deflate, sdch
Accept-Language: en-US,en;q=0.8
火狐
Host: localhost:xxxx
Connection: keep-alive
Content-Length: 179
Accept: application/json, text/plain, */*
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:44.0) Gecko/20100101 Firefox/44.0
Authorization: Bearer xxxx
Content-Type: application/json;charset=utf-8
Referer: http://localhost:xxxx/AddressType/Index
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.5
我想知道为什么内容长度不同
以下是所需的详细信息
我的角度JS函数调用webapi
service.put = function (ID, DataBundle) {
var request = $http({
method: "put",
url: url + "/" + ID,
data: { DataBundle: DataBundle }
}).catch(exceptionHandler);
return request;
}
DataBundle-->
Active:"Y"
Code:"0002"
CreateDate:null
CreateUser:null
Description:"Office Address"
ID:2
ModifyDate:"2015-10-19T02:15:06.6241496"
ModifyUser:1
Name:"Office"
__proto__:Object
来自chrome的put请求的服务器端代码 enter image description here
用于绑定传入模型的DTO类
public class ParamDTO
{
public int ID { get; set; }
public string Code { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public string Active { get; set; }
public Nullable<int> CreateUser { get; set; }
public Nullable<System.DateTime> CreateDate { get; set; }
public Nullable<int> ModifyUser { get; set; }
public Nullable<System.DateTime> ModifyDate { get; set; }
public bool Deleted { get; set; }
public Nullable<int> UserLevelID { get; set; }
public string StatusType { get; set; }
}
答案 0 :(得分:0)
完成了 我的angularJS调用功能有问题 这一行
data: { DataBundle: DataBundle }
应该是
data: DataBundle
我不确定为什么有时使用firefox。如果有人可以帮助解释这将是欣赏