2012-11-30 2 views
1

누군가 적절한 PUT 예제를 가르쳐 주거나 표시 할 수 있습니까?웹 API PUT 예제

내가 만난 모든 것이 모순되었습니다. 당신이 컨트롤러에 이미

답변

2

생각 .... 두 번째 예제 MVC 프레임 워크에서

[HttpPut] 
public HttpResponseMessage MyPutAction(myModelType MyModel) 
{ 
    .... 
    // here is some code that will update the record and return it as part of HttpResponseMessage 
    .... 

또는

public HttpResponseMessage Put(myModelType MyModel) .... 

이가 [넣어] 메소드 이름에 기반 것을 알고있다. 그래서 당신은

또는

public HttpResponseMessage PutMyModel(myModelType MyModel) .... 

바보 소리 그러나 다만 위와 같은 작품 [HttpPut]로 장식 할 필요가 없습니다. 다시 말하지만, MVC 프레임 워크는 메서드 이름에 기반하여 [Put]이 "Put"으로 시작하기 때문에이를 알고 있습니다.