标签:web configuration Service App Azure PHP 方法
问题描述
如何让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)\PHP\v7.3\php-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
标签:web,configuration,Service,App,Azure,PHP,方法 来源: https://www.cnblogs.com/lulight/p/15092019.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。