Just can't seem to find a clue about this one anywhere.
The Story(Diagram of the system) In the company i work in we have 5 IIS servers... In every server there are many websites(In every server the same sited) All the servers are behind a balancer so if you type the hostname you do not know to what server are you going to be directed to.
All the servers and for each server all its virtual websites are in the HOST file If I choose a server and a site in the host file I will be directed to this server and site and every thing is working.
Now my question I'm trying to connect to each of the servers and for each one check a page on it...
What happens is that i am all the time being redirected to the same server, not the different servers...
I am calling this code for each server, where the Url is the name of the page and "((WebPageTest)test).ServerAddress" changes for each server...
string htmlText = string.Empty;
try
{
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("http://www.MyDomain.com" + Url);
request.Host = ((WebPageTest)test).ServerAddress;
request.UserAgent = "Tests UserAgen";
WebResponse response = request.GetResponse();
Stream stream = response.GetResponseStream();
StreamReader reader = new StreamReader(stream);
htmlText = reader.ReadToEnd();
htmlText = "OK";
}
catch (Exception exp) {
htmlText = exp.Message;
}
return htmlText;
Any one knows maybe how to Connect to the right server and right website in every server so i will be able to check the page in each site?
EDIT: there is no way i can change setting in the balancer or the firewall or any thing like that.... I need to mimic what happen when using a host file. When no server is added to the host file, the balancer decide to which server to send the request to, but when i am using the host file i am directed to a specific server....This is what i need to do in code...Is there any thing to add to the header to do that and I've tried every thing i can think about?
Thank you very much,
Erez