2014-02-07 90 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"]; 
相關問題