user2835504
user2835504

Reputation: 31

POST verb not allowed

A bit basic, but I have tried some of the methods to tackle the following error but could not get the right solution.

<!DOCTYPE html>

<html lang="en">
    <head>
        <meta charset="utf-8" />
        <title></title>
    </head>
    <body>
        <form  method="post">
            <input type="text" name="query1"></input>
            <input type="text" name="query2"></input>
            <input type="submit"></input>

        </form>
    </body>
</html>

Error on running : HTTP Error 405.0 - Method Not Allowed The page you are looking for cannot be displayed because an invalid method (HTTP verb) is being used.

In the mappings of IIS, I have added the POST method but that did not work! Suggestions please!

Upvotes: 3

Views: 11607

Answers (3)

Dorad
Dorad

Reputation: 3683

The following code has solved the problem for me(it's for php on iis).

web.config:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <handlers accessPolicy="Read, Execute, Script">
            <remove name="PHP55_via_FastCGI" />
            <add name="PHP55_via_FastCGI" path="*.php" verb="*" modules="FastCgiModule" scriptProcessor="C:\Program Files (x86)\PHP\v5.5\php-cgi.exe" resourceType="Either" requireAccess="Script" />
            <add name="HTML_via_FastCGI" path="*.html" verb="*" modules="FastCgiModule" scriptProcessor="C:\Program Files (x86)\PHP\v5.5\php-cgi.exe" resourceType="Either" requireAccess="Script" />
            <add name="HTM_via_FastCGI" path="*.htm" verb="*" modules="FastCgiModule" scriptProcessor="C:\Program Files (x86)\PHP\v5.5\php-cgi.exe" resourceType="Either" requireAccess="Script" />
        </handlers>
        <security>
            <requestFiltering>
                <fileExtensions>
                    <add fileExtension=".php" allowed="true" />
                </fileExtensions>
                <verbs>
                    <add verb="POST"   allowed="true" />
                    <add verb="GET"    allowed="true" />
                    <add verb="HEAD"   allowed="true" />
                    <add verb="DELETE" allowed="true" />
                    <add verb="PUT"    allowed="true" />
                </verbs>
        </requestFiltering>
    </security>
</system.webServer>

Upvotes: 3

phpguest
phpguest

Reputation: 804

In my opinion you have 2 errors: 1) If your file extension is *.html change it to for example *.asp, *.php and it will work. 2)The input tag doesn't have closing tag.

Upvotes: 0

ediblecode
ediblecode

Reputation: 11971

Without seeing more, this could be a variety of problems. With that in mind, here is a list of possible fixes for your issue:

Cause 1

This problem occurs because the client makes an HTTP request by using an HTTP method that does not comply with the HTTP specifications.

To resolve this problem, see resolution 1.

Cause 2

This problem occurs because a client makes an HTTP request by sending the POST method to a page that is configured to be handled by the StaticFile handler. For example, a client sends the POST method to a static HTML page. However, pages that are configured for the StaticFile handler do not support the POST method.

To resolve this problem, see resolution 2.

Resolution 1

Make sure that the client sends a request that contains a valid HTTP method. To do this, follow these steps:

  1. Click Start, type Notepad in the Start Search box, right-click Notepad, and then click Run as administrator.
  2. Note If you are prompted for an administrator password or for a confirmation, type the password, or provide confirmation. On the File menu, click Open. In the File name box, type %windir%\system32\inetsrv\config\applicationhost.config, and then click Open.
  3. In the ApplicationHost.config file, locate the tag.
  4. Make sure that all the handlers use valid HTTP methods.
  5. Save the ApplicationHost.config file.

Resolution 2

Send the POST request to a page that is configured to be handled by a handler other than the StaticFile handler (for example, the ASPClassic handler). Or, change the request that is being handled by the StaticFile handler so that it is a GET request instead of a POST request.

MSDN Source

Upvotes: 1

Related Questions