Although DELETE
request works successfully locally, it does not work when I deploy my app to MS Azure.
Here is what I get in console when try to delete a record:
DELETE http://mywebsite.azurewebsites.net/api/subjects/1 405 (Method Not Allowed)
My app uses mySQL
at cleardb
How to fix such a problem?
EDIT
My app is a PHP 5.5 app, here is what I tried to do in web.config
to enable DELETE and PUT, but it didn't work:
<?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>
Configuring IIS on PHP. Step 1. First enable IIS on your machine go to Programs and Feature ⇒ Turn Windows feature on or off as shown in below image and check all the check box inside IIS [ Internet Information Service ]. Step 2. After window enable all IIS feature search IIS on start menu and open it and start your server. Step 3.
To get PUT and DELETE to be accepted by IIS 7.5 for a PHP 5.4 fast-CGI driven REST API I had to disable the WebDAV-module. Otherwise the WebDAV module intervenes the HTTP requests using PUT or DELETE. To get this working was however a bit confusing and I might have missed some steps or done it in another order.
In the IIS Manager, select the application that needs to support PUT. In the Features View, find WebDAV Authoring Rules . Double-click it, or select Open Feature from the context menu (right-click). In the Actions pane, find and click on WebDAV Settings....
In order for PHP to run properly on IIS there is a set of recommended settings that need to be configured in IIS and PHP. PHP Manager checks if all of the recommended settings are configured correctly. If some settings are not configured properly then you can use PHP Manager to fix those settings.
I think PUT and DELETE are disabled in WebApi / IIS8 by default, which is what it looks like you are using. Quite a bit of discussion on this here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With