将请求放入 chrome 未绑定 DTO

Put Request in chrome is not binding DTO

我遇到了一个奇怪的问题,虽然花了很多时间但仍然无法解决

之前提出的请求工作正常我遇到了问题

Failed to load resource: the server responded with a status of 404 (Not Found) 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 模型是空的,这个仅在 put 请求时发生,所有其他请求都正常工作,例如 get、getall、delete、post,这仅在 chrome 中发生。在 Firefox 中,put 请求工作正常。

我无法理解 ModelState 是否为真那么为什么 chrome 没有将数据绑定到我的 DTO 下面分别是 chrome 和 Firefox 的 header 请求

Chrome

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

我想知道为什么内容长度不同

以下是需要的详细信息

我的angular调用webapi的JS函数

 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 的放置请求的服务器端代码 enter image description here

DTO class绑定传入模型

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; }
    }

完成了 我的 angularJS 调用函数有问题 这条线

data: { DataBundle: DataBundle }

应该是

 data: DataBundle 

我不确定为什么它有时与 Firefox 一起工作。如果有人可以对此做出贡献,那将不胜感激