getting an HTTP 405 on IIS

i was trying to set up this web application to connect to a HTTP server (happened to be IIS) that is serving some pre-generated report files. The offshore developer that had been working on this had some problems getting it going, so it was left to me to deal with it. The web application was using Apache HttpClient to connect to the http server using some standard http client code below:

<snip>

HttpClient client = new HttpClient();

PostMethod method = new PostMethod(filePath);
method.setRequestHeader("Content-type", "text/html");
client.executeMethod(method);
input = method.getResponseBodyAsStream();
responseBean.setInputStream(input);

</snip>


that resulted in IIS throwing this at us......

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

Please try the following:

Contact the Web site administrator if you believe that this request should be allowed.
Make sure that the Web site address displayed in the address bar of your browser is spelled and formatted correctly.

HTTP Error 405 - The HTTP verb used to access this page is not allowed.
Internet Information Services (IIS)

Technical Information (for support personnel)

Go to Microsoft Product Support Services and perform a title search for the words HTTP and 405.
Open IIS Help, which is accessible in IIS Manager (inetmgr),
and search for topics titled Setting Application Mappings, Securing Your Site with Web Site Permissions, and About Custom Error Messages.



So basically what was happening was that IIS didn't like the POST method that was being used. (HTTP 405 --> Method Not Allowed). The fix? quite simple, use a GET! =) It is easy to forget that POST's primary objective is to post data to the server, not to obtain data from it.

As web devs, we see HTTP 404s a lot...and the occasional 403. it's not everyday you see a 405!

Comments (0)

Post a Comment