2014-02-07 64 views
0

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

这应该是相当简单的,但找不到正确的方法?

这里是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==?= 

回答

0

此发现自己

var httpContext = (HttpContextWrapper)Request.Properties["MS_HttpContext"]; 
     var OrgCodePK = httpContext.Request.Form["OrgCode_PK"]; 
相关问题