1

We moved our web service to a new website and we need to redirect all the calls to https://www.example.com/LicenseServer.asmx to https://licensing.example.com/LicenseServer.asmx but for an unknown reason, it fails with an exception.

Are these rules unsuitable for ASMX web service files?

Should I make this change at IIS level instead?

    <rule name="Licensing redirection" stopProcessing="false">
        <match url="LicenseServer.asmx" ignoreCase="true" />
        <action type="Redirect" url="https://licensing.example.com/LicenseServer.asmx" redirectType="Permanent" appendQueryString="true" logRewrittenUrl="true" />
    </rule>

I've already checked also this answer: https://stackoverflow.com/a/45939030/261010

abenci
  • 8,422
  • 19
  • 69
  • 134

1 Answers1

0

You could try rule as below:

 <system.webServer>
        <rewrite>
            <rules>
                <rule name="testrule" stopProcessing="true">
                    <match url="(.*)" />
                    <conditions>
                        <add input="{REQUEST_URI}" pattern="service1.asmx" />
                    </conditions>
                    <action type="Redirect" url="http://localhost:882/test1.asmx" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>

Please set the file and hostname based on your requirement.

here is the output:

enter image description here

Jalpa Panchal
  • 8,251
  • 1
  • 11
  • 26
  • Thanks for answering. Unfortunately I get this exception: `Unexpected error while contacting http://www.example.com/LicenseServer.asmx. Client found response content type of 'text/html; charset=utf-8', but expected 'text/xml'.` It returns the HTML code of the output page you have in your answer. What else should I try? – abenci Apr 15 '22 at 09:29
  • @abenci could you confirm that the destination url "https://licensing.example.com/LicenseServer.asmx" is working fine without the url rewrite rule – Jalpa Panchal Apr 15 '22 at 12:21
  • Yes of course. We use both and want to discontinue the first. Your test is not operational, it simply shows that the correct endpoint is reached displaying the correct HTML. We need to execute the code on the web services instead. – abenci Apr 15 '22 at 12:29