View Complete Thread
  • IIS 7.5 adding 'Document Moved' content when 'Location' header is present

    Apr 11, 2014 10:13 AM|lmirguet|LINK

    Hello,

    Using PHP 5.4 and IIS 7.5, I'm trying to develop some REST web services compliant with the HAL specification.

    In this context, when we create an object with a POST request, the expect result is a 201 http response with the Location header targetting the object URL and the JSON of the object created in the content.

    For example the response to my POST request could be :

    Status Code:201 Created
    Location:http://localphp.aufeminin.com/reloaded/manage/admin/api/user/58
    {"id":58,
     "username":"h",
      "_links":{
         "self":{"href":"http:\/\/localphp.aufeminin.com\/reloaded\/manage\/admin\/api\/user\/58"}
      }
    }

    But it seems, that as soon as we have a Location header, IIS adds a 'Document Moved' section to the content.

    For example in this case :

    <head><title>Document déplacé</title></head>
    <body><h1>Objet déplacé</h1>Ce document peut être consulté <a HREF="http://localphp.aufeminin.com/reloaded/manage/admin/api/user/58">ici</a></body>
    {"id":58, "username":...

    How can I disable this behavior of IIS ? How can I avoid the 'Document moved' html content while keeping the Location header ?

    Thanks a lot for your help,

    Laurent Mirguet