我可以用AcceptVerbs(HttpVerbs.Post)/AcceptVerbs(HttpVerbs.Get)来装饰一个动作
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Create(string title)
{
// Do Something...
}或使用HttpPost/HttpGet属性
[HttpPost]
public ActionResult Create(string title)
{
// Do Something...
}它们是不同的吗?
发布于 2010-10-02 08:41:26
没什么。其中一个只是对另一个的速记。
发布于 2013-04-16 18:08:48
[HttpPost]是[AcceptVerbs(HttpVerbs.Post)]的缩写。唯一的区别是,您不能在同一操作上同时使用[HttpGet, HttpPost] (和类似的)。如果希望操作同时响应GET和POST,则必须使用[AcceptVerbs(HttpVerbs.Get | HttpVerbs.Post)]。
https://stackoverflow.com/questions/3843875
复制相似问题