Reputation: 23
I have an ASP.NET application with web api controllers and angular client. I call to web api in the next way:
this.$http.get('api/menu/get', {
params: {}
})
So I call to absolute path like http://myApp/api/menu/get. And now I should get some data from another web application, url example: http://secondApp/reportsApi/reports/get.
How to get data from secondApp web api? As I know I can just call absolute path from UI like
this.$http.get('http://secondApp/reportsApi/reports/get', {
params: {}
})
But it doesn't looks like good decision. I wont to make calls like:
this.$http.get('reportsApi/reports/get', {
params: {}
})
And in some way redicrect this calls from "myApp" to "secondApp".
Upvotes: 2
Views: 993
Reputation: 7545
This describes how you can use the built in IIS rewrite modules.
http://www.iis.net/learn/extensions/url-rewrite-module/creating-rewrite-rules-for-the-url-rewrite-module
You will end up with something like this in your web.config:
<system.webServer>
<rewrite>
<rules>
<rule name="Redirect Reports Api" stopProcessing="true">
<match url="^reportsApi/reports/get" />
<action type="Rewrite" url="http://secondApp/reportsApi/reports/get" />
</rule>
<rules>
<rewrite>
<system.webServer>
Upvotes: 1