zoukankan      html  css  js  c++  java
  • 【Azure 应用服务】如何让App Service 支持 Delete 方法 

    问题描述

    如何让webapp 支持 delete 方法? 在不修改设置的情况下,调用DELETE方法出现405错误 - 方法不被允许

    问题解决

    基于当前App Service在Windows的环境中运行,所以可以使用配置IIS的方式在web.config中对Delete方法进行允许访问,正确的设置如下:

    <configuration>
       <system.webServer>
          <security>
             <requestFiltering>
                <verbs applyToWebDAV="false">
                   <add verb=" DELETE" allowed=" true" />
                </verbs>
             </requestFiltering>
          </security>
       </system.webServer>
    </configuration> 

    :如果App Service中不包含web.config,可以进入Kudu站点( https://<your site name>.scm.chinacloudsites.cn/DebugConsole )创建,或者在您的项目文件根目录中创建后一起部署到App Service

    如是PHP项目应用,文件中需要加上PHP Handler 设置(以PHP 7.3版本举例,需根据实际情况修改):

    <configuration>
       <system.webServer>
          <security>
             <requestFiltering>
                <verbs applyToWebDAV="false">
                   <add verb=" DELETE" allowed=" true" />
                </verbs>
             </requestFiltering>
          </security>
       </system.webServer>
       <handlers>
            <remove name="PHP73x86_via_FastCGI" /> 
            <!-- We instruct to delete the existing handler with that name -->
            <add name="PHP73x86_via_FastCGI" path="*.php" verb="GET,HEAD,POST,DELETE" modules="FastCgiModule" scriptProcessor="D:Program Files (x86)PHPv7.3php-cgi.exe" resourceType="Either" /> 
            <!-- We give the new values for the handler. It is basically the  old handler but we added the DELETE method to the verbs -->
        </handlers>
    </configuration> 

    参考资料

    拒绝HTTP请求方法的示例(Configuration Sample)https://docs.microsoft.com/en-us/iis/configuration/system.webserver/security/requestfiltering/verbs/#configuration-sample

     

    当在复杂的环境中面临问题,格物之道需:浊而静之徐清,安以动之徐生。 云中,恰是如此!

  • 相关阅读:
    Demo:刮刮卡橡皮擦效果
    养成良好的代码编写习惯
    我的百科
    专业英语词汇
    加载资源的类
    循环滚动翻页+居中项缩放
    学习笔记—Node中模块化规范
    学习笔记—Node中的EventLoop
    学习笔记—Node的全局对象
    学习笔记—Node的基本概念
  • 原文地址:https://www.cnblogs.com/lulight/p/15092019.html
Copyright © 2011-2022 走看看