2
下面是一個POST URL與內容類型application/x-WWW窗體-urlencoded天冬氨酸MVC模式與內容類型application/x-WWW窗體-urlencoded
POST
http://partner-site.com/api_implementation/hotel_availability
BODY
api_version=4
&hotels=[{"ta_id":97497,"partner_id":"229547","partner_url":"http://partner.com/deeplink/to/229547"},{"ta_id":97832,"partner_id":"id34234","partner_url":"http://partner.com/deeplink/to/id34234"}]
&start_date=2013-07-01
&end_date=2013-07-03
&num_adults=2
&num_rooms=1
&lang=en_US
¤cy=USD
&user_country=US
&device_type=d
&query_key=6167a22d1f87d2028bf60a8e5e27afa7_191_1360299600000_2_2
CONTENT TYPE
application/x-www-form-urlencoded
,我已經寫了所述陣列的結合類,讀起來像
public class HotelAvailabilityRequest
{
public int api_version { get; set; }
public List<HotelSummary> hotels { get; set; }
public string start_date { get; set; }
public string end_date { get; set; }
public int num_adults { get; set; }
public int num_rooms { get; set; }
public string lang { get; set; }
public string query_key { get; set; }
public string currency { get; set; }
public string user_country { get; set; }
public string device_type { get; set; }
}
public class HotelSummary
{
public int ta_id { get; set; }
public string partner_id { get; set; }
public string partner_url { get; set; }
}
,當我在我的ASP MVC方法
public ActionResult Hotel_Availability(HotelAvailabilityRequest request)
{}
我得到o使用HotelAvailabilityRequest療法參數一樣request.api_version,request.device_type除了request.hotels
我得到request.hotels.Count()等於零。
我如何得到request.hotel以相應地進行綁定?
嘗試更改內容類型爲'application/json' –
POST請求由我無法控制的第三方進行。任何其他方式? –
您必須創建一個自定義模型聯編程序。 http://www.dotnetcurry.com/showarticle.aspx?ID=584 –