How to get a host name behind a load balancer in ASP.NET?
I have a couple of servers and a load balancer. I want to show a server name which is currently serving the page.
I am using H开发者_运维百科ttpContext.Current.Request.ServerVariables["SERVER_NAME"]
and HttpContext.Current.Request.ServerVariables["LOCAL_ADDR"]
but is shows the same data for all servers (load balancer information is shown but not the information about exact server name).
How to get a relevant information?
Try System.Environment.MachineName
.
Perhaps Server.MachineName
does what you are looking for?
Page.Request.ServerVariables["HTTP_HOST"].ToUpper();
精彩评论