Reputation: 1809
I have two web servers with public IPs, for example Server1 with IP 111.111.111.111
and Server2 with IP 222.222.222.222
. Please see the picture:
There is an asp.net webform at Server 1. My intention is:
My questions are:
Upvotes: 2
Views: 2235
Reputation: 1275
Ok, this is a strange solution to that strange question :)
Basically I will assume the Client requests to an aspx web page as a QUESTION and the reply from Server as ANSWER. From the diagram, I will again assume that Server2 is the ANSWERER to that QUESTION.
In order for the Question and Answer session to work, and also due to internet behavior, I will implement it in a 2 steps process:
Step 1: Client ask question and Server1 returns the url of the answer. This url will be pointed on Server2. Server2 needs to pass this url via lan to Server1)
Step 2: Client makes request to retrieve the answer in Server2.
In summary, Client will directly request webform from Server1 and retrieve response from Server2. All operations are initiated by the Client.
Upvotes: 1
Reputation: 7600
The best solution for this problem is to setup a WCF web service on the other server.
ASP.NET WCF/Web Services supports interoperability with WCF applications running on the same Windows machine or WCF running on a different Windows machines or standard Web services built on platforms
Review following articles on msdn:
ASP.NET Windows Communication Foundation in .NET
Upvotes: 2
Reputation: 61057
If you just wanna do request forwarding that's a simple matter of just forward the request to server2 by invoking a second request from server1 to server2. You then return that response as the response of server1 to the client. You cannot make server2 talk directly to the client because the client did not connect to server2.
I would use System.Net.HttpWebRequest
and just set HTTP headers and content bodies based of the original request (effectively replaying the exact same message sent to server1 on server2) then return the response from server2 to the client.
If you did this you would be running an application which just forwards any requests to server2 and thus running a dummy application. This application can be very simple because in truth it is little more than a HTTP proxy.
Yet, I have to ask again, to what end? Are your building some kind of request filtering mechanism? because I believe there are better ways to solve that problem.
Upvotes: 1
Reputation: 4360
Well, client is connected Server 1 via http. that's ok but you want Server 2 to respond over TCP. this seems very unlikely to me, because clien doenst know anything about Server 2.
You might want to internally connect your server 2 from server 1 over tcp do your stuff and return your response from Server 1 to your client. ( Server 2 is acting like session state server for example)
If you are trying to load balancing its another story. Actually if you can tell us why you need such an architecture maybe you might get better answers.
Upvotes: 1
Reputation: 1885
We may need some more information about your scenario, but I don't think that Server2 can send the response back to the client.
The client still has an open socket listening for a response from Server1.
In order to accomplish something like this you may need to add some sort of proxy to the mix. Like this: client sends to proxy who sends to server 1, who sends to server 2, who sends response to proxy, who sends response to client.
Or have Server1 act as your proxy.
Upvotes: 1
Reputation: 40160
This sounds very suspicious to me, like something a phisher would want to do to hide the phishing attempt.
You really can't have a different server send a response directly back to the client than the one which directly receives the request. No client would accept such a response.
If this is a legitimate operation here, you need a proxy that accepts the request, and forwards the response back.
Upvotes: 1