asp.net-mvcで2つのオーバーロードされたアクションメソッド(1つはGETアクション用、もう1つはPOSTアクション用)を使用して、post-redirect-getパターンを実装することは可能ですか?
すべてのMVCpost-redirect-getパターンサンプルで、post-redirect-getプロセスの3つの異なるアクションメソッド(Initial Get、Post、およびRedirection Getに対応)を確認しました。それぞれの名前は異なります。これは、 asp.net-mvcで、異なる名前のアクションメソッドを少なくとも3つ持つ必要がありますか?
例:(以下に示すコードは、Post-Redirect-Getパターンに従いますか?)
public class SomeController : Controller
{
// GET: /SomeIndex/
[HttpGet]
public ActionResult Index(int id)
{
SomeIndexViewModel vm = new SomeIndexViewModel(id) { myid = id };
//Do some processing here
return View(vm);
}
// POST: /SomeIndex/
[HttpPost]
public ActionResult Index(SomeIndexViewModel vm)
{
bool validationsuccess = false;
//validate
if (validationsuccess)
return RedirectToAction("Index", new {id=1234 });
else
return View(vm);
}
}
}
ご回答ありがとうございます。