How to get a host name behind a load balancer in ASP.NET?

旧城冷巷雨未停 提交于 2019-12-10 22:45:05

问题


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?


回答1:


Try System.Environment.MachineName.




回答2:


Perhaps Server.MachineName does what you are looking for?




回答3:


Page.Request.ServerVariables["HTTP_HOST"].ToUpper();


来源:https://stackoverflow.com/questions/3512707/how-to-get-a-host-name-behind-a-load-balancer-in-asp-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!