How to get a host name behind a load balancer in A

2019-07-21 13:59发布

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 HttpContext.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?

3条回答
Deceive 欺骗
2楼-- · 2019-07-21 14:36

Try System.Environment.MachineName.

查看更多
成全新的幸福
3楼-- · 2019-07-21 14:42

Perhaps Server.MachineName does what you are looking for?

查看更多
成全新的幸福
4楼-- · 2019-07-21 14:50
Page.Request.ServerVariables["HTTP_HOST"].ToUpper();
查看更多
登录 后发表回答