Enabling POST requests for html files in IIS7

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.


Solution 1:

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" />

Solution 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/