0

From this question, I concluded that

Response.Redirect simply sends a message (HTTP 302) down to the browser.

Server.Transfer happens without the browser knowing anything, the browser request a page, but the server returns the content of another. So doesn't send to another server.

Problem:

I have two servers, running IIS webserver. Server 1 receives api calls from clients, the clients have different databases, some on server 1, others on server 2.

if the DB of the client is on Server 2, then his API call shall be redirected to server 2.

Note that you can tell from the URL which server an API call should be routed

What do I want?

I want a server-side redirect method capable of redirecting to another server. in order to redirect the API calls.

(And if there's any better way of doing what I'm asking for, like a proxy or some software, that big companies use, please let me know)

Community
  • 1
  • 1
Lynob
  • 5,059
  • 15
  • 64
  • 114
  • Is there anyway to tell from the URL which server an API call should be routed? If so then I'd think there are networking tools that would split the load as a common solution here. – JB King Dec 22 '15 at 22:44
  • @JBKing yes you can tell from the url of course – Lynob Dec 22 '15 at 22:46
  • 2
    Then you just need to make the IIS server act as a proxy. If the URL starts with `/server1`, forward the request to server 1, and so on. – CodeCaster Dec 22 '15 at 22:52
  • 2
    The most common solution to this is to setup a third server that handles all requests and routes to the appropriate server. You can do this with [IIS](http://weblogs.asp.net/owscott/creating-a-reverse-proxy-with-url-rewrite-for-iis), [Nginx](https://www.digitalocean.com/community/tutorials/understanding-nginx-http-proxying-load-balancing-buffering-and-caching) or many other servers out there. – Chris Haas Dec 22 '15 at 22:55
  • Most large companies would have a load balancer that would route requests to the proper server though this seems more like a comment than an answer. – JB King Dec 22 '15 at 22:56
  • @ChrisHaas thanks i'll take a look – Lynob Dec 22 '15 at 23:09
  • @CodeCaster thank you – Lynob Dec 22 '15 at 23:09

0 Answers0