我们可以在Mvc4中将HTTPPOST actionAttribute设置为默认操作吗? [英] Can we set HTTPPOST actionAttribute as default action in Mvc4?

查看:164
本文介绍了我们可以在Mvc4中将HTTPPOST actionAttribute设置为默认操作吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们可以在Mvc4中将HTTPPOST actionAttribute设置为默认操作吗?请尽快提出建议.

Can we set HTTPPOST actionAttribute as default action in Mvc4? Please suggest as soon as possible.

推荐答案

我了解的内容:
默认操作同时接受POST和GET方法.您可以使用[HttpPost]属性指定HTTP方法,

-可以使用属性指定HTTP方法:AcceptVerbs,HttpDelete,HttpGet,HttpHead,HttpOptions,HttpPatch,HttpPost或HttpPut.

-否则,如果控制器方法的名称以"Get","Post","Put","Delete","Head","Options"或"Patch"开头,则按照惯例,该操作支持该HTTP方法.

-如果以上都不是,则该方法支持POST.


有关更多详细信息,您可以通过以下页面导航至操作选择:
http://www.asp.net/web-api/overview/web-api-routing-and-actions/routing-and-action-selection [
what i understand :
The default action accept both POST and GET method, You can specify the HTTP method with using of the [HttpPost] attribute,

- can specify the HTTP method with an attribute: AcceptVerbs, HttpDelete, HttpGet, HttpHead, HttpOptions, HttpPatch, HttpPost, or HttpPut.

- Otherwise, if the name of the controller method starts with "Get", "Post", "Put", "Delete", "Head", "Options", or "Patch", then by convention the action supports that HTTP method.

- If none of the above, the method supports POST.


for more details you can navigate to Action Selection through this page :
http://www.asp.net/web-api/overview/web-api-routing-and-actions/routing-and-action-selection[^]


这篇关于我们可以在Mvc4中将HTTPPOST actionAttribute设置为默认操作吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆