简体   繁体   中英

IIS Load Balancing and ASP.Net

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!

System.Environment.MachineName怎么样

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM