Search code examples
asp.netazureumbracoazure-web-app-serviceurldecode

Url Decoding not working on Azure Web app


I seem to be having an issue with Url's being decoded on the stage site incorrectly. I have been looking around online but I can't seem to find anything on how to switch what decoding method is used by default. I can tell that the stage site is using Windows-1252 to decode urls, example below:

Stage site (Wrong)

de-de/people/%C3%A1ine-hurley/ -> de-de/people/áine-hurley

Dev site (Correct)

de-de/people/%C3%A1ine-hurley/ -> de-de/berater/áine-hurley

The dev an live site are both rendering the correct url, which is being decoded using UTF-8. for a comparasion of decoding characters you can visit this link http://www.w3schools.com/tags/ref_urlencode.asp

I am at a loss really, Both stage and live are setup in Azure web apps and from what I can see have the same settings (however I have a feeling it is probably a server setting somewhere).

If anyone could give me more information on how this works or if its possible to change decoding settings on a server that would be much appreciated. If any more information is needed, I am happy to provide it. I was just unsure of what information would be useful.


Solution

  • After more investigation, I noticed the stage site was actually issuing 301 permanent redirects to a URL that had first been decoded using windows-1252 then re-encoded as UTF-8 (this is very peculiar, as I can't find anywhere in code that would have done this, nor could I find anything in the rewrite rules).

    However this was resolved by adding in a permanent canonical redirect to resolve the staging site without www. and force it to stage.sitename.come. Example canonical below:

    <rule name="Redirect to WWW" stopProcessing="true" >
        <match url="(.*)" />
        <conditions>
            <add input="{HTTP_HOST}" pattern="^www\." negate="true"/>
        </conditions>
        <action type="Redirect" url="https://www.{HTTP_HOST}{HTTP_URL}" redirectType="Permanent" appendQueryString="false" />
    </rule>
    

    If someone knows why this would resolve the issue, would love to know :). Hope this helps someone else if they have this problem.