AcceptPostAttribute

The AcceptPostAttribute is an extension of the MVC Framework's AcceptVerbsAttribute, which allows you to mark an action as accessible only through an HTTP POST.

By default, if you want to ensure that an action can only be accessed through an HTTP Post, you would have to prefix it with an AcceptVerbs attribute:

[AcceptVerbs("POST")]
public ActionResult MyAction() {
  return View();
}


With the AcceptPost attribute, the need to explicitly specify the verbs has been removed. This makes the code slightly more compiler safe:

[AcceptPost]
public ActionResult MyAction() {
  return View();
}

AcceptGetAttribute

The AcceptGetAttribute is very similar to the AcceptPostAttribute, except that it makes an action only accessible via an HTTP Get:

[AcceptGet]
public ActionResult MyAction() {
  return View();
}

Last edited Sep 13, 2008 at 3:33 PM by JeremyS, version 1

Comments

JeremyS Apr 2, 2010 at 2:27 PM 
maird, yes - these are now deprecated.

maird Apr 2, 2010 at 12:27 PM 
Are these now deprecated by the HttpPost and HttpGet attributes in MVC2?