zoukankan      html  css  js  c++  java
  • HttpPost与HttpVerbs.Post属性的区别

    1、

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

     从MVC 2.0之后HttpPost属性成为HttpVerbs.Post的简化版。

    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)]. 

     HttpPost是AcceptVerbs(HttpVerbs.Post)的简称。唯一区别就是HttpPost和HttpGet属性不能同时用在同一个方法上;

     如果想希望在一个方法上实现Gets和Posts,必须用[AcceptVerbs(HttpVerbs.Get | HttpVerbs.Post)]。

    3、

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

    [AcceptVerbs]是修饰一个方法来接受多种动作的唯一方式。

    [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")]

  • 相关阅读:
    springBoot异常处理
    webSocket
    Java正则
    String.format
    JSTL-taglib
    http meta
    chrome 常用插件下载安装
    mysql 命令行个性化设置
    Entity Framework Code First
    SignalR Connection has not been fully initialized
  • 原文地址:https://www.cnblogs.com/Herzog3/p/5139671.html
Copyright © 2011-2022 走看看