第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

WebAPI多個(gè)Put / Post參數(shù)

WebAPI多個(gè)Put / Post參數(shù)

慕容3067478 2019-09-20 16:19:49
我試圖在WebAPI控制器上發(fā)布多個(gè)參數(shù)。一個(gè)參數(shù)來自URL,另一個(gè)參數(shù)來自正文。這是網(wǎng)址: /offers/40D5E19D-0CD5-4FBD-92F8-43FDBB475333/prices/這是我的控制器代碼:public HttpResponseMessage Put(Guid offerId, OfferPriceParameters offerPriceParameters){    //What!?    var ser = new DataContractJsonSerializer(typeof(OfferPriceParameters));    HttpContext.Current.Request.InputStream.Position = 0;    var what = ser.ReadObject(HttpContext.Current.Request.InputStream);    return new HttpResponseMessage(HttpStatusCode.Created);}正文的內(nèi)容是JSON:{    "Associations":    {        "list": [        {            "FromEntityId":"276774bb-9bd9-4bbd-a7e7-6ed3d69f196f",            "ToEntityId":"ed0d2616-f707-446b-9e40-b77b94fb7d2b",            "Types":            {                "list":[                {                    "BillingCommitment":5,                    "BillingCycle":5,                    "Prices":                    {                        "list":[                        {                            "CurrencyId":"274d24c9-7d0b-40ea-a936-e800d74ead53",                            "RecurringFee":4,                            "SetupFee":5                        }]                    }                }]            }        }]    }}知道為什么默認(rèn)綁定無法綁定到offerPriceParameters我的控制器的參數(shù)?它始終設(shè)置為null。但是我能夠使用the從身體恢復(fù)數(shù)據(jù)DataContractJsonSerializer。我也嘗試使用FromBody參數(shù)的屬性,但它也不起作用。
查看完整描述

3 回答

?
慕標(biāo)琳琳

TA貢獻(xiàn)1830條經(jīng)驗(yàn) 獲得超9個(gè)贊

如果正在使用屬性路由,則可以使用[FromUri]和[FromBody]屬性。


例:


[HttpPost()]

[Route("api/products/{id:int}")]

public HttpResponseMessage AddProduct([FromUri()] int id,  [FromBody()] Product product)

{

  // Add product

}


查看完整回答
反對 回復(fù) 2019-09-20
  • 3 回答
  • 0 關(guān)注
  • 1254 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)