什么是ActionResult的AcceptVerbsAttribute默认的HTTP方法? [英] What are the ActionResult AcceptVerbsAttribute default HTTP methods?
本文介绍了什么是ActionResult的AcceptVerbsAttribute默认的HTTP方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道你可以通过添加AcceptVerbsAttribute,例如限制哪些HTTP方法特定的ActionResult方法响应。
I know you can restrict which HTTP methods a particular ActionResult method responds to by adding an AcceptVerbsAttribute, e.g.
[AcceptVerbs(HttpVerbs.Get)]
public ActionResult Index() {
...
}
但我想知道:哪些HTTP方法一个ActionResult方法将接受的没有的一个明确的的[AcceptVerbs(...)] 属性
我想presume是获取 HEAD 和发表但只是想仔细检查。
I would presume it was GET, HEAD and POST but was just wanting to double-check.
感谢。
推荐答案
没有 AcceptVerbsAttribute
你的动作
将接受请求任何HTTP方法。顺便说一句,你可以限制在RouteTable HTTP方法:
Without AcceptVerbsAttribute
your Action
will accept requests with any HTTP methods. BTW you can restrict HTTP methods in your RouteTable:
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = "" }, // Parameter defaults
new { HttpMethod = new HttpMethodConstraint(
new[] { "GET", "POST" }) } // Only GET or POST
);
这篇关于什么是ActionResult的AcceptVerbsAttribute默认的HTTP方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文