1
在控制器端點的路由上定義可選參數的正確語法是什麼?在路由中定義可選參數的Web.Api
[Route("customers/{customerId}/boats/{boatId}/bookings{contractId?}&{startDate?}&{endDate?}&{outOnly?}", Name = "GetBookingsByBoat")]
[ResponseType(typeof (IEnumerable<BookingSummaryDTO>))]
public IHttpActionResult Get(int customerId, int boatId, int? contractId, DateTime? startDate, DateTime? endDate, bool outOnly = false)
{
上述編譯,但是當我嘗試並調用使用
customers/40/boats/24/bookings
端點我得到:
{"message":"The requested resource does not support http method 'GET'."}
千恩萬謝