12

尽管DELETE请求在本地成功运行,但当我将我的应用程序部署到 MS Azure 时它不起作用。

这是我在尝试删除记录时在控制台中得到的信息:

DELETE http://mywebsite.azurewebsites.net/api/subjects/1 405 (Method Not Allowed)

我的应用使用mySQLcleardb

如何解决这样的问题?

编辑

我的应用程序是 PHP 5.5 应用程序,这是我尝试web.config启用 DELETE 和 PUT 的方法,但它不起作用:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
        <rules>
        <rule name="Imported Rule 1" stopProcessing="true">
        <match url="^(.*)$" ignoreCase="false" />
        <conditions logicalGrouping="MatchAll">
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                        </conditions>
                        <action type="Rewrite" url="index.php?url={R:1}" appendQueryString="true" />
                </rule>
            </rules>
        </rewrite>

<validation validateIntegratedModeConfiguration="false" />
    <modules runAllManagedModulesForAllRequests="true">
      <remove name="WebDAVModule" />
    </modules>
    <security>
      <requestFiltering>
        <verbs applyToWebDAV="false">
          <add verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS,XYZ" allowed="true" />
        </verbs>
      </requestFiltering>
    </security>

         <handlers>
<remove name="PHP55_via_FastCGI" />
  <add name="PHP55_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.5\php-cgi.exe" resourceType="Either" requireAccess="Script" />

              <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
              <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
              <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
              <add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS,XYZ" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
              <add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS,XYZ" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
              <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS,XYZ" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
            </handlers>

    </system.webServer>
</configuration>
4

3 回答 3

2

我认为 PUT 和 DELETE 默认在 WebApi / IIS8 中被禁用,这就是你正在使用的样子。在这里对此进行了相当多的讨论。

于 2015-05-18T15:18:54.683 回答
2

我们需要在 Web.Config 文件中添加一些配置,如此处所述。

http://blog.maartenballiauw.be/post/2012/12/07/Configuring-IIS-verbs-for-ASPNET-Web-API-on-Windows-Azure-Websites-and-elsewhere.aspx

于 2015-05-18T17:10:32.420 回答
2

据我所知,只需转到 IIS 用户界面,然后请求过滤,然后是 HTTP 动词。最后为想要的动词添加一个新的允许规则

于 2015-05-25T08:59:45.263 回答