15

I am struggling for days to enable PUT and DELETE request for my PHP app at MS Azure. Some answers I found suggest to remove the WebDAV module from IIS.

How would I do so?

Opal
  • 81,889
  • 28
  • 189
  • 210
Samir Sabri
  • 937
  • 3
  • 11
  • 26
  • I have this problem also. It looks like APPCMD might be the only option but I've still not been able to successfully edit the config for my app service in the auzre/kudu console. If I sort it out I'll add an answer. – shiitake Aug 17 '16 at 14:26

6 Answers6

9

I've spent a whole day on this and tried every solution I ran into yet nothing worked for me. What finally worked was turning off the "WebDAV Publishing" feature from Turn Windows features on or off. This is located under:

Internet Information Services\World Wide Web Services\Common HTTP Features\WebDAV Publishing.

Ninos
  • 224
  • 4
  • 18
7
  1. Go to your site in IIS
  2. Click "Modules"
  3. Remove WebDAVModule
  4. Restart site (might not be needed)

PUT and DELETE requests should now work.

Eric Bynum
  • 471
  • 7
  • 7
6

I am hosting a PHP application in Azure App Services and I was able to solve this problem by manually creating a file called web.config and adding it to the root directory of my web application.

Here is the entire content of that file.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <security>
        <requestFiltering>
            <verbs allowUnlisted="false">
                <add verb="GET" allowed="true" />
                <add verb="POST" allowed="true" />
                <add verb="DELETE" allowed="true" />
                <add verb="PUT" allowed="true" />
            </verbs>
        </requestFiltering>
    </security>
    <modules runAllManagedModulesForAllRequests="true">
      <remove name="WebDAVModule" />
    </modules>
    <handlers>
      <remove name="WebDAV" />
      <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
      <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
      <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
      <remove name="PHP56_via_FastCGI" />
      <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" />
      <add name="PHP56_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.6\php-cgi.exe" resourceType="Either" requireAccess="Script" />
    </handlers>
  </system.webServer>
</configuration>

You'll notice in the handlers section it references PHP56_via_FastCGI. This is specific to PHP 5.6. If you are using a different version of PHP you will need to update the name and file path to reflect that version.

shiitake
  • 231
  • 2
  • 6
4

sometimes I just can't believe that the same people who worked on the great .Net Core have worked on IIS and all this madness to say the least. I kept searching and trying to figure out what was the issue, furthermore I tried the best I can to log the error 405 Method not allowed but to no avail. I didn't want to alter the web.config file and didn't want to remove this pointless WebDavModule thingy because my site is hosted along other sites other people working on so I didn't want to ruin the day for anyone else.

Now, this emotional introduction aside, I managed to make it work via simple IIS Configuration steps. Imagine a figurative sarcastically double-quotes mark surrounding the word simple.

So here is what you can do:

  1. Open IIS manager
  2. Go to the site level you want to enable PUT, DELETE verbs for.
  3. From Handler Mappings click on WebDav and then click Edit
  4. Click on Request Restrictions and from there navigate to Verbs tab
  5. Chose All verbs and finally click OK. I swear this UI is more confusing than a whole map for the human brain neurons connections.
  6. Restart the Web Site because I did that just-in-case because I had enough headache for the following few months.
Rickless
  • 1,377
  • 3
  • 17
  • 36
0

I think there is already solution for your problem in previous post in stackoverflow.

Try this out and hopefully it helps! https://stackoverflow.com/a/16275723/3203213

Community
  • 1
  • 1
juvchan
  • 6,113
  • 2
  • 22
  • 35
  • But that solution depends on the user interface, like: (Control Panel -> Uninstall Program -> Turn Windows features on or off -> IIS -> World Wide Web Services -> Common HTTP feautre -> WebDAV Publishing) meanwhile, I can only use the terminal, is there a way to use remote desktop for Azure? – Samir Sabri May 24 '15 at 07:36
0

This response is good. Basically put it in the Web.config. This is what @shiitake is doing.

I've beeen using that solution for a while but its annoying because I have to maintain it in my Web.config when the rest of the developers don't. So I removed it from IIS all together.

  1. Open IIS and go to the site in question.
  2. Click on "Handler Mappings"
  3. Find the handler named "WebDAV"
  4. Select it and Remove it

On first try I got, Error: Cannot write configuration file due to insufficient permissions. Full disclosure, my coworker fixed it for me and sent the following instructions. (Maybe someone can edit and clarify the steps.)

  1. Stop the site
  2. Add yourself to Security Group
  3. Remove the handler.
christo8989
  • 6,442
  • 5
  • 37
  • 43
  • 1
    This answer got me really close... remove WebDAV from "Modules" instead of "Handler Mappings" and that is all you should have to do on your site in IIS. – Eric Bynum Aug 09 '21 at 15:58