내 webservice에서 공개 할 기능에 대해 간단한 REST API를 수행하려고합니다.ASP.NET 웹 API 2 - 매개 변수가 지원되지 않는 GET
[RoutePrefix("companies")]
public class CompaniesController : BaseApiController {
[HttpGet, Route("{companyId:int}")]
public CustomResponse Get(int companyId) { }
[HttpPost]
public CustomResponse Post(CompanySaveViewModel model) { }
[HttpDelete, Route("{companyId:int}"]
public CustomResponse Delete(int companyId) { }
}
이 기능이 작동합니다. POST 메서드가 제대로 작동합니다.
나는 주어진 URL을 사용하여 이러한 메서드 호출하려고 해요 :
http://localhost:11111/api/companies/1 [GET]
http://localhost:11111/api/companies/1을 내가 GET 및/또는 방법을 DELETE 호출 할 때, 나는 아래의 메시지를 받았습니다
POST 잘 작동 [삭제]. 매개 변수없이 GET 을 호출하려고하면 잘 작동합니다. 문제는 GET/DELETE 메서드에 대한 매개 변수가있을 때 나타납니다. 여기에 무슨 문제가있을 수 있습니까?
도움을 주셔서 감사합니다.
'RoutePrefix'를 제거하고 같은 것을 시도하십시오 –