【问题标题】:get/post in a generic handler在通用处理程序中获取/发布
【发布时间】:2012-01-25 00:44:17
【问题描述】:
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]

这两个哪个是get,哪个是post? 它用于通用处理程序(.ashx 文件)。

【问题讨论】:

    标签: asp.net post get generic-handler


    【解决方案1】:

    ScriptMethod 允许您在 Get 场景中调用方法。否则需要通过 POST 调用

    MSDN

    【讨论】:

      【解决方案2】:
      [WebMethod]
      [ScriptMethod(UseHttpGet = true/false, ResponseFormat = ResponseFormat.Json)]
      public bool UseHttpGet { set; get; }
      Member of System.Web.Script.Services.ScriptMethodAttribute
      

      总结: 获取或设置一个值,该值指示是否使用 HTTP GET 调用方法。

      返回: 如果使用 HTTP GET 命令调用该方法,则为 true;如果使用 HTTP POST 命令调用该方法,则为 false。默认为假。

      我们可以同时创建 get 和 post 方法

      【讨论】:

        猜你喜欢
        • 2022-01-02
        • 2013-03-02
        • 2023-04-04
        • 1970-01-01
        • 2012-07-18
        • 2015-10-27
        • 1970-01-01
        • 1970-01-01
        • 2016-05-04
        相关资源
        最近更新 更多