如何在 Azure 中启用 PUT 请求? [英] How do I enable PUT requests in Azure?

查看:36
本文介绍了如何在 Azure 中启用 PUT 请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在 Azure 上构建 REST API,但是当我尝试通过 PUT 方法访问端点时,我收到 HTTP 405Method Not Allowed" 状态以及 IIS 错误消息:

I'm building a REST API on Azure, but when I try to access an endpoint via the PUT method I get a HTTP 405 "Method Not Allowed" status along with an IIS error message:

您要找的页面无法显示,因为无效正在使用方法(HTTP 动词).

The page you are looking for cannot be displayed because an invalid method (HTTP verb) is being used.

如何启用 PUT 方法以及其他可能被 Azure 默认配置设置默认阻止的方法?

我尝试将 web.config 文件添加到我的应用程序的根目录,并在动词元素上将 allowUnlisted 设置为 true:

I tried adding a web.config file to the root of my application with allowUnlisted set to true on the verbs element:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
   <system.webServer>
      <security>
         <requestFiltering>
            <verbs applyToWebDAV="false" allowUnlisted="true" />
         </requestFiltering>
      </security>
   </system.webServer>
</configuration>

这没有任何改变.

我是一个开源的人,所以 IIS 的世界对我来说非常陌生.任何帮助表示赞赏.

I'm an open source guy, so the world of IIS is very unfamiliar to me. Any help is appreciated.

谢谢!

推荐答案

system.webServer 元素的 web.config 中添加以下内容:

Add the following to the web.config in the system.webServer element:

<handlers>
  <remove name="PHP54_via_FastCGI" />
  <add name="PHP54_via_FastCGI" path="*.php" verb="GET, PUT, POST, HEAD, OPTIONS, TRACE, PROPFIND, PROPPATCH, MKCOL, COPY, MOVE, LOCK, UNLOCK" modules="FastCgiModule" scriptProcessor="D:Program Files (x86)PHPv5.4php-cgi.exe" resourceType="Either" requireAccess="Script" />
</handlers>

这适用于 PHP 的内置版本,当前默认为 PHP 5.4,但如果您选择了 PHP 5.3 或 PHP 5.5,则需要修改 php-cgi 处理程序的路径.

This works for the built in versions of PHP, the current default is PHP 5.4, but if you have selected PHP 5.3 or PHP 5.5 you will need to modify the path of the php-cgi handler.

这篇关于如何在 Azure 中启用 PUT 请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆