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

  • 相关阅读:
    二叉树的遍历
    深度优先遍历和广度优先遍历
    N的阶乘末尾有多少个0
    框架产生的历史
    Ansible--初始ansible
    日积跬步05
    日积跬步04
    日积跬步03
    日积跬步02
    日积跬步01
  • 原文地址:https://www.cnblogs.com/Herzog3/p/5139671.html
Copyright © 2011-2022 走看看