0
基於下面的代碼,我能夠調用/ API /卡/ API /卡/清單,但現在/ API /卡/ 1234567890網頁API控制器與多個POST和單put方法
WebApiConfig
config.Routes.MapHttpRoute(_
name:="WithActionAndIdApi", _
routeTemplate:="api/{controller}/{action}/{id}", _
defaults:=New With {.id = RouteParameter.Optional} _
)
config.Routes.MapHttpRoute(_
name:="WithIdApi", _
routeTemplate:="api/{controller}/{id}" _
)
config.Routes.MapHttpRoute(_
name:="DefaultApi", _
routeTemplate:="api/{controller}", _
defaults:=New With {.action = "DefaultAction"} _
)
CardsController
<HttpPost()>
<ActionName("DefaultAction")>
Public Function PostValue(<FromBody()> ByVal value As Card_POST.Card) As HttpResponseMessage
<HttpPost()>
<ActionName("list")>
Public Function PostValue(<FromBody()> ByVal value As Cards_POST.CardList) As HttpResponseMessage
<HttpPut()>
Public Function PutValue(ByVal Id As String, <FromBody()> ByVal value As Card_PUT) As HttpResponseMessage
請確保您提出問題。目前還不清楚你有什麼問題或你正試圖解決什麼問題。 – chambo
你如何做PUT請求? – Mate
@Mate,我通過更改我的config.Routes – belltric