博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[HttpPost] vs [AcceptVerbs(HttpVerbs.Post)]
阅读量:5129 次
发布时间:2019-06-13

本文共 773 字,大约阅读时间需要 2 分钟。

[HttpPost] vs [AcceptVerbs(HttpVerbs.Post)] is there a difference?

1、

the HttpPost attribute is a short for the HttpVerbs.Post one but since MVC 2.0.

 

2、

[HttpPost] is shorthand for [AcceptVerbs(HttpVerbs.Post)].  The only difference is that you can't use [HttpGet, HttpPost] (and similar) together on the same action.  If you want an action to respond to both GETs and POSTs, you must use [AcceptVerbs(HttpVerbs.Get | HttpVerbs.Post)].

 

3、

[AcceptVerbs] is the only way to decorate a method that accepts several (but not all) verbs.

[AcceptVerbs(HttpVerbs.Post | HttpVerbs.Put)]

It's also the only way you can specify a verb that's not one of the "core four", such as those which are part of WebDAV:

[AcceptVerbs("LOCK")]

转载于:https://www.cnblogs.com/jhxk/articles/2615615.html

你可能感兴趣的文章
virutalenv一次行安装多个requirements里的文件
查看>>
Vue安装准备工作
查看>>
.NET 母版页 讲解
查看>>
Android Bitmap 和 Canvas详解
查看>>
最大权闭合子图
查看>>
oracle 创建暂时表
查看>>
201421410014蒋佳奇
查看>>
导入导出数据库和导入导出数据库表
查看>>
linux下操作mysql
查看>>
【03月04日】A股滚动市盈率PE历史新低排名
查看>>
Xcode5和ObjC新特性
查看>>
jvm slot复用
查看>>
高并发系统数据库设计
查看>>
hdu 1875 畅通工程再续
查看>>
CentOs6和Centos7安装docker
查看>>
TCP/ip协议栈之内核调优
查看>>
6 spark 存储体系 --内存管理
查看>>
PDF/WORD/EXCEL 图片预览
查看>>
onRetainNonConfigurationInstance方法状态保存
查看>>
DevExpress组件之——TreeList组件
查看>>