Reputation: 47387
Until now I have always just used post
and get
on my controller actions.
I'd like to use all of the major verbs in my app in order to [a] adhere to standards for rest, and [b] well, not use get and post exclusively.
The additional verbs I'd like to use are
What is the most straightforward way of achieving this? I know that all of the required verbs (other than patch
) are available for [AcceptVerbs(...)]
, but I'm not fully sure how to implement them.
Upvotes: 1
Views: 83
Reputation: 2542
You can override the post method in the view as follows,
<% using (Html.BeginForm("MyAction","MyController",FormMethod.Post))
{
%>
<%:Html.HttpMethodOverride(HttpVerbs.Put) %>
<%
} %>
Then in the Controller, you can have [HttpPut]
Upvotes: 1
Reputation: 93444
The easiest way is to use the MVC4 beta that was just released, and this includes the new WebAPI that will automatically do restful requests. You can even install only the WebAPI and use it under MVC3. It includes a go-live license as well.
However, if you're stuck with non-beta then you have to do a little more work. Here's a good rundown.
http://iwantmymvc.com/rest-service-mvc3
Upvotes: 1