locked
Map .aspx as .xml extension and pass query string RRS feed

  • Question

  • User-1063667917 posted

    Hi,

    Most of popular email clients use autodiscovery to get the mail server configuration calling an xml in a location but passing data as querystring:

    https://autoconfig.domain.com/mail/config-v1.1.xml?emailaddress=user@domain.com

    And the result must be an xml

    So far, I can show autodiscovery.xml and show the xml (eventhough the real file name is autodiscovery.aspx):

    <system.webServer>
        <rewrite>
          <rewriteMaps>
            <rewriteMap name="/Autodiscover/Autodiscover.xml">
              <add key="/Autodiscover/Autodiscover.xml" value="/Autodiscover/Autodiscover.aspx" />
            </rewriteMap>
          </rewriteMaps>
          <rules>
            <rule name="Rewriting to /Autodiscover/Autodiscover.xml">
              <match url=".*" />
              <conditions>
                <add input="{/Autodiscover/Autodiscover.xml:{REQUEST_URI}}" pattern="(.+)" />
              </conditions>
              <action type="Rewrite" url="{C:1}" appendQueryString="false" />
            </rule>
          </rules>
        </rewrite>
        <httpErrors errorMode="DetailedLocalOnly" />
      </system.webServer>

    The problem comes when I pass the querystring, it returns:

    HTTP Error 404.0 - Not Found

    The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.

     What am I doing wrong? or is there another way to do it and I'm taking the hard way?

    Regards

    Sunday, August 5, 2018 10:15 AM

Answers

  • User753101303 posted

    Hi,

    Try with those changes :

    <conditions>
       <add input="{/Autodiscover/Autodiscover.xml:{URL}}" pattern="(.+)" />
    </conditions>
    <action type="Rewrite" url="{C:1}" appendQueryString="true" />

    REQUEST_URI includes the query string. URL does the match only on the URL part and then the querystring is appended.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, August 5, 2018 12:25 PM

All replies

  • User753101303 posted

    Hi,

    Try with those changes :

    <conditions>
       <add input="{/Autodiscover/Autodiscover.xml:{URL}}" pattern="(.+)" />
    </conditions>
    <action type="Rewrite" url="{C:1}" appendQueryString="true" />

    REQUEST_URI includes the query string. URL does the match only on the URL part and then the querystring is appended.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, August 5, 2018 12:25 PM
  • User-1063667917 posted

    That did the job !!!

    Thank you Patrice

    Sunday, August 5, 2018 7:31 PM