IIS and ASP.Net load balancing

Basically, I have 3 servers, where 1 of them serves as a load balancer.

On my ASPX page, I want to add an HTML comment to show the IP address or even the host name of the server selected by the load balancer.

I tried to look at IIS Server variables and tried to use SERVER_NAME , but it just returns the domain url.

So, is there a way to do this programming in ASP.NET? Thank!

+3
source share
2 answers

What about System.Environment.MachineName

+6
source

For IP address:

HttpContext.Current.Request.ServerVariables["LOCAL_ADDR"].ToString(); 

For the local server name:

System.Net.Dns.GetHostName();

EDIT:

@ Conrad (System.Environment.MachineName) .

+3

Source: https://habr.com/ru/post/1757877/


All Articles