Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Problem
There have been quite a few other questions about this (in particular, the 405 Method Not Allowed error), but I've yet to find a solution that seems to work.

I have a web application in html and javascript only (no backend) and the javascript uses POST in forms. I understand that IIS sees html files as static and only allows them to use GET and HEAD verbs, so when a form is posted I'm getting "405 Method Not Allowed...cannot be displayed because an invalid method (HTTP verb) is being used".

Configuration
I have a default installation of IIS 7 on a Win 7 machine. By default ISAPI/CGI/ASP etc, and WebDav are all disabled/not installed. The only setting I've changed is added read/write for some of the features under Feature Delegation.

Under Handler Mappings on the Default Site I have OPTIONSVerbHandler, TRACEVerbHandler and StaticFile. The StaticFile request restrictions shows all verbs enabled, access read, invoke handler only if request is mapped to file or folder.

System.Web.DefaultHttpHandler properties show the verbs GET, HEAD and POST.

Tried so far
If I set up another Handler Mapping, duplicating OPTIONS but setting ther verb to POST instead, the 405 error is gone, but I get a blank page instead.

As suggested near the bottom of this question, I tried adding this to my web.config, but it didn't seem to have any effect:

<add name="HttpPost"/>

(I also did the same with the config GUI, and also added HttpPostLocalhost.)

I've tried changing post to POST in the html (just in case), but that had no effect.

I've also tried explicitly allowing the verbs under Request Filtering, but that didn't help either.


Does anyone have any other ideas? I assume it will work if I install asp and change all of my file extensions, but that seems unnecessary.

share|improve this question
    
possible duplicate of How to tell IIS7 to allow POST to a text file (to solve 405)? –  Shane Madden Jan 10 '12 at 23:30
    
@Shane Madden; I've tried the answer to that question already (checking verbs for static file handler) and it didn't work. He probably had IIS set up differently already. –  Demelziraptor Jan 11 '12 at 8:35

2 Answers 2

Add the ISAPI modules, and add a script processing handler for "*.html" files, mapping them to e.g. the default asp handler, in you're web.config.

See this blog post: http://zhongchenzhou.wordpress.com/2011/12/05/iis-7-7-5-allow-post-requests-to-html-files/

share|improve this answer
    
I don't have the asp.dll as in that blog post; will I need to install ASP for this method? –  Demelziraptor Jan 10 '12 at 23:21
    
(It looks like it's just handing html files to the asp interpreter? I'd like to avoid that if possible as it seems overkill to install asp just for this.) –  Demelziraptor Jan 10 '12 at 23:31
up vote 0 down vote accepted

So it looks like posting to html files is impossible in IIS without installing a backend language to interpret the html files rather than the IIS static file handler. If anyone knows differently, please let me know! (Just to make it clear, Apache does not have this problem.)

The post linked to by @JudasIscariot1651 works, however, it requires installing ASP and will break your site if you're using a backend language that isn't ASP (presumably only if posting to html pages - I wasn't able to test). You need to configure whatever language you're using to handle the html files instead of the static file handler.

If you're not using a backend language, or are using ASP, here's a copy of the ASP version (access permissions modified to example in post) - install ASP and ISAPI first:

<add name="html" path="*.html" verb="*" modules="IsapiModule" scriptProcessor="%windir%\system32\inetsrv\asp.dll" resourceType="Unspecified" requireAccess="None" />

If you're using PHP, you need to use the following (adjust for PHP settings) - presumably you already have PHP and CGI installed:

<add name="html" path="*.html" verb="*" modules="FastCgiModule" scriptProcessor="C:\Program Files (x86)\PHP\php-cgi.exe" resourceType="Unspecified" requireAccess="None" />
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.