3 回答

TA貢獻1818條經(jīng)驗 獲得超11個贊
從此:
config.Routes.MapHttpRoute("API Default", "api/{controller}/{id}",
new { id = RouteParameter.Optional });
對此:
config.Routes.MapHttpRoute("API Default", "api/{controller}/{action}/{id}",
new { id = RouteParameter.Optional });
因此,您現(xiàn)在可以指定要將HTTP請求發(fā)送到的操作(方法)。
發(fā)布到“ http:// localhost:8383 / api / Command / PostCreateUser”會調(diào)用:
public bool PostCreateUser(CreateUserCommand command)
{
//* ... *//
return true;
}
并發(fā)布到“ http:// localhost:8383 / api / Command / PostMakeBooking”會調(diào)用:
public bool PostMakeBooking(MakeBookingCommand command)
{
//* ... *//
return true;
}
我在自托管的WEB API服務(wù)應(yīng)用程序中嘗試了此方法,它的工作原理很像:)
- 3 回答
- 0 關(guān)注
- 965 瀏覽
添加回答
舉報