tags:

views:

7288

answers:

6

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 ... 
</form>

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

A: 

It sounds like the server is having trouble handling POST requests (get and post are verbs). I don't know, how or why someone would configure a server to ignore post requests, but the only solution would be to fix the server, or change your app to use get requests.

mike
But this has to be deterministic, right? There must be something that causes one form to fail and all the others to work.
drewm
A: 

Try adding a name and id attribute to your form.

John Rasch
This sounds ridiculous, but I've seen the same suggested elsewhere. Apparently it's due to an ASP.net bug. Hasn't helped in this case, though.
drewm
+2  A: 

By any chance have you tried POST vs post? This support article suggests it can cause problems with IIS: http://support.microsoft.com/?id=828726

David Carrington
Because, according to RFC 2616 (HTTP/1.1), RFC-defined method tokens are upper-cased, and all are case-sensitive.
GZipp
Changing POST to uppercase didn't change the behaviour.
drewm
post does not differ from POST ->html is case insensitive
madicemickael
+2  A: 

The acceptable verbs are controlled in web.config (found in the root of the website) in <system.web><httpHandlers> and possibly <webServices><protocols>. Web.config will be accessible to you if it exists. There is also a global server.config which probably won't. If you can get a look at either of these you may get a clue.

The acceptable verbs can differ with the content types - have you set Content-type headers in your page at all ? (i.e. if your Content-type was application/json then different verbs would be allowed)

Andiih
Unfortunately, the customer's shared hosting environment doesn't offer access to system.web/httpHandlers.
drewm
For clarity and those unfamiliar with .net I should have written - <System.web><httpHandlers> - this is a section within web.config, normally found in the root of the website, not a file system path. I will edit my post to reflect that, although I see you have now solved it!
Andiih
+3  A: 

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.

Util::redirect('/apps/content');

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:

Util::redirect('/apps/content/');

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

drewm
A: 

Just encountered this error on Tomcat.It is usually because you try to access from index.html(welcome-file-list) a post/get method.Redirect to another page an there put your form .It should work.

madicemickael