IIS 7.5 adding 'Document Moved' content when 'Location' header is presentRSS

6 replies

Last post Aug 20, 2014 11:55 AM by DropPhone

  • 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

  • Re: IIS 7.5 adding 'Document Moved' content when 'Location' header is present

    Apr 16, 2014 09:46 AM|Perkinsville|LINK

    Hi,

    Try an outbound URL Rewrite rule.

    HTH, Benjamin

  • Re: IIS 7.5 adding 'Document Moved' content when 'Location' header is present

    Apr 17, 2014 12:21 PM|lmirguet|LINK

    Hello,

    Thanks for your answer but I don't really understand how this would help me.

    I see that an outbound rule can modify on-the-fly the URL provided by the field Location:. But I don't want to change the value of this field, I just want to avoid IIS to add some content to my response.

    Did I miss something in your answer ? Did you mean something else ?

    Thanks for your help,

    Laurent

  • Re: IIS 7.5 adding 'Document Moved' content when 'Location' header is present

    May 30, 2014 06:38 PM|Ravindra_A|LINK

  • DropPhone DropPhone

    360 Posts

    Microsoft

    Moderator

    Re: IIS 7.5 adding 'Document Moved' content when 'Location' header is present

    Jun 02, 2014 11:37 AM|DropPhone|LINK

    lmirguet

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

    Just to confirm, the 201 status response is returned to the client, yes?

    If the correct response status code is coming back, but you just have a problem with the HTML, you might try configuring PHP to go through the ISAPI FastCGI interface, instead of the native CGI handler.  See: http://www.iis.net/learn/application-frameworks/install-and-configure-php-on-iis/configuring-the-fastcgi-extension-for-iis-60 (yes, it says IIS 6.0, but the config will still work on IIS 7+).  You'll need to disable the native FastCGI handler mapping after you've configured the ISAPI FastCGI handler.

    There are some known behavior differences between the ISAPI FastCGI handler, and the native IIS7+ FastCGI handler.  There have been similar reports where the ISAPI one behaves differently in the case of the Location: header.

    Thx!

        --E.

  • Re: IIS 7.5 adding 'Document Moved' content when 'Location' header is present

    Aug 19, 2014 02:51 PM|kentbrockman|LINK

    DropPhone

    try configuring PHP to go through the ISAPI FastCGI interface



    This can't be the solution [I tried a little, didn't get it to work]. Why does IIS has to add html content and even change the MIME-type? There is just no reason for that. This behaviour breaks so much software.

    ATM I'm trying to get OwnCloud run on my IIS 8.5 machine, but the contacts webinterface is not working because of this bug. It relies on correct HTTP headers with json content appended. The only solution seems to be using a custom location header and a rewrite rule...

    Would be happy for a real fix (stop IIS changing the HTTP answers).

  • DropPhone DropPhone

    360 Posts

    Microsoft

    Moderator

    Re: IIS 7.5 adding 'Document Moved' content when 'Location' header is present

    Aug 20, 2014 11:55 AM|DropPhone|LINK

    kentbrockman

    Would be happy for a real fix (stop IIS changing the HTTP answers).

    I'm not entirely sure if I'm allowed to disclose this, but a bug for this issue has been filed & fixed for the next version of Windows (a.k.a. Threshold).

    Thx!

        --E.