0

我正在破坏 WebAPI 中的 ModelBinding 错误,我看到主键被发布回服务器,但在模型属性中的服务器上,键始终为空。我决定进一步检查它,看看请求对象是否能够检索该值,如果是的话,我将继续实现我自己的自定义模型绑定器。但是知道我遇到了另一个问题,我无法弄清楚如何使用 Request Object 提取值?

这本来应该很简单,但找不到正确的方法?

这是 Postinformation,其中 OrgCode_PK 是属性提供问题。

Request URL:http://localhost:1398/api/Org/PutOrg
Request Method:PUT
Status Code:404 Primary Key Not found
Request Headersview source
Accept:application/json, text/javascript, */*; q=0.01
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Content-Length:473
Content-Type:application/x-www-form-urlencoded; charset=UTF-8
Cookie:sbOverlayID=52335384; __iswl_localhost:1398=0; __ctxpop=1
Host:localhost:1398
Origin:http://localhost:1398
Referer:http://localhost:1398/main.html
User-Agent:Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36
X-Requested-With:XMLHttpRequest
Form Dataview sourceview URL encoded
$inlinecount:allpages
OrgCode_PK:ORG6
OrgHeadCode_FK:ORGH12
Code:CBSE-KHN
Name:khkl modified
Description:jhjkh
Address1:hjkh
Address2:jkhkj
CountryCode_FK: edf
CountryName:abyu
StateCode_FK:klh
StateName:yhu
CityCode_FK:hjkh
CityName:khk
ZIP:67u8
RowStatusCode_FK:NEW
RowStatus:NEW ROW
DateCreated:02-06-2014
DateUpdated:02-06-2014
EffectiveDate:02-11-2014
TerminationDate:05-21-2014
CreatedByUserName:jkhkjhkj
UpdatedByUserName:kjkljlk
RowStatusName:NEW ROW
Response Headersview source
Cache-Control:no-cache
Content-Length:41
Content-Type:text/plain; charset=utf-8
Date:Fri, 07 Feb 2014 17:24:52 GMT
Expires:-1
Pragma:no-cache
Server:Microsoft-IIS/8.0
X-AspNet-Version:4.0.30319
X-Powered-By:ASP.NET
X-SourceFiles:=?UTF-8?B?QzpcUHJvamVjdHNcU01XaXRoQXV0aGVudGljYXRpb25cU000XFNNNFxhcGlcT3JnXFB1dE9yZw==?=
4

1 回答 1

0

我自己找到了这个

var httpContext = (HttpContextWrapper)Request.Properties["MS_HttpContext"];
        var OrgCodePK = httpContext.Request.Form["OrgCode_PK"];
于 2014-02-08T01:53:46.647 回答