4

My requirement is for all POST requests to a specific REST API endpoint in my legacy application to be re-routed to a new endpoint (both are implemented using ASP.NET Web API). The new endpoint is hosted under the same parent website in IIS but runs within a separate application pool.

My first thought was to configure a URL Rewrite rule in IIS but unfortunately it isn't possible to rewrite a URL across application pools without introducing other components into the mix, such as Application Request Routing, which isn't feasible for us.

Another option I considered was to set the action of the URL Rewrite rule to "Redirect" instead of "Rewrite". The difference is explained here. Using this approach re-routes the request to the new endpoint, however it converts it from a POST to a GET request and therefore fails. The endpoint must accept a POST request with the expected parameters specified in the POST body and return an appropriate response to the originator.

Another option is to implement an Owin middleware in my legacy application that checks each request and if the URL is destined for the specific endpoint then rebuild the POST request from the originating one and send it to the new endpoint and subsequently return the response to the sender. I had considered returning a 302 Redirect instead of rebuilding the request but this would result in the sender issuing a GET request to the redirected URL, instead of a POST. Returning a 307 is yet another option, as explained here, but this may result in a security warning and also isn't universally supported.

I would appreciate any other suggestions for implementing this.

aw1975
  • 1,669
  • 3
  • 20
  • 35
  • Maybe this will help https://learn.microsoft.com/en-us/iis/extensions/configuring-application-request-routing-arr/creating-a-forward-proxy-using-application-request-routing – Alex Lyalka Dec 07 '17 at 13:14

0 Answers0