Reputation: 6514
Basically, I have 3 servers where 1 of them serves as a load balancing server.
In my ASPX page, I want to add a HTML comment to show the IP address or even host name of the server selected by the load balancer.
I tried looking through IIS Server variables and tried using SERVER_NAME but that just returns the domain URL.
So, is there any way to do this programming in ASP.NET? Thanks!
Upvotes: 3
Views: 1362
Reputation: 46763
For IP address:
HttpContext.Current.Request.ServerVariables["LOCAL_ADDR"].ToString();
For local server hostname:
System.Net.Dns.GetHostName();
EDIT:
@Conrad's answer above (System.Environment.MachineName
) also works for the host name.
Upvotes: 3