Reputation: 520
Can someone point me to or show me a proper PUT example?
Everything I've come across has been inconsistent.
Upvotes: 1
Views: 2949
Reputation: 19340
Thinking that you are already in controller....
[HttpPut]
public HttpResponseMessage MyPutAction(myModelType MyModel)
{
....
// here is some code that will update the record and return it as part of HttpResponseMessage
....
or
public HttpResponseMessage Put(myModelType MyModel) ....
In the second example MVC framework knows that this is [Put] based on the Method name. So you don't need to decorate it with [HttpPut]
or
public HttpResponseMessage PutMyModel(myModelType MyModel) ....
Sounds stupid but works just like the one above. Again, MVC framework knows that this is [Put] based on the Method name, because it starts with "Put".
Upvotes: 3