In ASP.NET MVC Should A Form Post To Itself Or Another Action?
Posted
by Sohnee
on Stack Overflow
See other posts from Stack Overflow
or by Sohnee
Published on 2010-05-28T09:12:51Z
Indexed on
2010/05/28
9:41 UTC
Read the original article
Hit count: 239
asp.net-mvc
|best-practices
Which of these two scenario's is best practice in ASP.NET MVC?
1 Post to self
In the view you use
using (Html.BeginForm) {
...
}
And in the controller you have
[HttpGet]
public ActionResult Edit(int id)
[HttpPost]
public ActionResult Edit(EditModel model)
2 Post from Edit to Save
In the view you use
using (Html.BeginForm("Save", "ControllerName")) {
And in the controller you have
[HttpGet]
public ActionResult Edit(int id)
[HttpPost]
public ActionResult Save(EditModel model)
Summary
I can see the benefits of each of these, the former gives you a more restful style, with the same address being used in conjunction with the correct HTTP verb (GET, POST, PUT, DELETE and so on). The latter has a URL schema that makes each address very specific.
Which is the correct way to do this?
© Stack Overflow or respective owner