Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Html.Action - Get versus Post

Tags:

I do this very often:

<div id='Product'>
@Html.Action("Create", "Product")
</div>

it's convenient because I can delegate the painting of a product creation form to another controller action for embedding in places. However, I'm having issues in that the method will sometimes (I haven't figured out under what conditions) call the [HttpPost] of my controller action, which of course fails.

Is there a way to force @Html.Action() to call the GET version?

like image 469
ekkis Avatar asked Jul 02 '11 03:07

ekkis


1 Answers

The way Html.Action works is that if the current request for the page is a post method then it will search for the method with the name HttpPost.

So what's happening is that you're POSTing the current page and the action likewise assumes all actions that should execute must be a POST too.

There's no way I know of to force it to switch to a different method like that.

like image 133
Buildstarted Avatar answered Sep 20 '22 03:09

Buildstarted