Search code examples
c#asp.netweb-servicesiisasmx

IIS redirect/rewrite .asmx service


I have searched around for the answer to this but cant find anything that fits my exact scenario.

Currently have the below set up :

RootApplication(sitea.bla) .NET 3.5

- ChildApplication (sitea.bla/service1) .NET 3.5

The root application is being rewritten in .NET 4.5 but the service1 application will not be being updated in this current phase and will be removed as an child application.

I have moved the service1 application to a sub domain (service1.sitea.bla)so it can run in an legacy application pool.

This works perfectly though I have multiple other applications/services/clients that reference the original endpoint. I have set up a IIS redirect which works perfectly in the browser

sitea.bla/service1/exampleservice.asmx gets redirected to service1.sitea.bla/exampleservice.asmx

Though when making a call through a client application it fails unless I manually change the endpoint to the new sub domain . I have also tried achieving through a reverse proxy.

What is the best method to achieve this without manually changing all the endpoints to the new sub domain?


Solution

  • You need to setup correct rewrite rule:

    1) You need to install ARR module (you need it, because you rewriting requests to different application)

    2) In IIS manager you should enable reverse proxy

    2.1) On server node click "Application Request Routing Cache"

    2.2) Click "Server proxy settings" and click "Enable proxy", then "Apply"

    3) In web.config of application sitea.bla add this rewrite rule:

    <rule name="rewrite service1" stopProcessing="true">
        <match url="^service1(.*)" />
        <action type="Rewrite" url="http://service1.sitea.bla{R:1}" />
    </rule>
    

    4) Try to make a call to sitea.bla/service1/exampleservice.asmx