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

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

问题描述

我正在Azure上构建REST API,但是当我尝试通过PUT方法访问端点时,我得到 HTTP 405方法不允许状态带有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文件添加到我的应用程序的根目录,并在verbs元素上将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)\PHP\v5.4\php-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天全站免登陆