Search code examples
xmlpostiishttpsiis-10

IIS serve XML and "accept but ignore" POST


I have a request from a developer to "accept but ignore" POST requests made to an XML file on an IIS server. It is used for testing something I don't understand. By default, when I put the XML file in the IIS site root and access it via the browser (GET) I get the response I expect. However, if I run the following command:

curl --data "test=test" https://server/example.xml

I get this response:

405 - HTTP verb used to access this page is not allowed. The page you are looking for cannot be displayed because an invalid method (HTTP verb) was used to attempt access.

He just wants a 200 response even if you send POST data. I found an old SO question that pointed to this article, but it is a very old version of IIS and when I tried it it did not help. I tried adding an XML handler mapping but no matter what I picked for "type" I kept getting other errors (usually ASP.net).


Solution

  • It looks like the instructions from this forum post are working. The trick was adding a "script" map instead of a regular handler.

    1. Open IIS Manager and navigate to the level you want to manage.
    2. In Features View, on the server, site, or application Home page, double-click Handler Mappings.
    3. On the Handler Mappings page, in the Actions pane, click Add Script Map.
    4. In the Request path box, type *.xml.
    5. In the Executable box, type %systemroot%\system32\inetsrv\asp.dll.
    6. In the Name box, type a friendly name for the handler mapping.
    7. Click OK.