What causes an HTTP 405 "invalid method (HTTP verb)" error when POSTing a form to PHP on IIS?


I have one form in a PHP (5.2.9-1) application that causes IIS (Microsoft-IIS/6.0) to throw the following error when POSTed:

The page you are looking for cannot be displayed because an invalid method (HTTP verb) was used to attempt access.

It's an HTTP 405 status code. All other forms in the application work, so I believe that the IIS 'verbs' setting for PHP pages is correct.

This is a customer's server, which I have no access to for verifying settings or testing code. All I can do is send the customer replacement files. Other customers on IIS servers have no such issue.

The form is perfectly straightforward:

<form method="post" action="index.php">
    ... fields ... 

What can cause IIS to throw that error on one form only, but work fine on others?

7/6/2012 9:52:36 AM

Accepted Answer

I managed to get FTP access to the customer's server and so was able to track down the problem.

After the form is POSTed, I authenticate the user and then redirect to the main part of the app.


The error was occurring not on the posting of the form, but on the redirect immediately following it. For some reason, IIS was continuing to presume the POST method for the redirect, and then objecting to the POST to /apps/content as it's a directory.

The error message never indicated that it was the following page that was generating the error - thanks Microsoft!

The solution was to add a trailing slash:


IIS could then resolve the redirect to a default document as is no longer attempting to POST to a directory.

9/10/2009 9:50:59 AM

I am deploying VB6 IIS Applications to my remote dedicated server with 75 folders. The reason I was getting this error is the Default Document was not set on one of the folders, an oversight, so the URL hitting that folder did not know which page to server up, and thus threw the error mentioned in this thread.

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow