[英]How to get DNS name in load balancing environment?
I have 4 servers participating in load balancing environment. 我有4台服务器参与负载均衡环境。 The same ASP.NET application is being hosted in each server.
每个服务器都托管相同的ASP.NET应用程序。 I would like to get the DNS Name regardless of the underlying server.
无论基础服务器如何,我都希望获得DNS名称。 Which one of the followings will give the correct answer?
以下哪一项会给出正确的答案?
Request.Url.Host
Environment.MachineName
System.Net.Dns.GetHostName()
Thanks for your suggestion! 谢谢你的建议!
You could try Request.Url.GetLeftPart(UriPartial.Authority)
. 您可以尝试
Request.Url.GetLeftPart(UriPartial.Authority)
。 So for example if the request url is http://www.contoso.com/index.htm?date=today
this will return http://www.contoso.com
. 例如,如果请求网址为
http://www.contoso.com/index.htm?date=today
则返回http://www.contoso.com
。
The first. 首先。 It actually is the ONLY one that is even vaguely relevant.
它实际上是唯一一个甚至模糊相关的人。
Anyhjoe, both my not be what is used to access the machine. Anyhjoe,我不是用来访问机器的东西。 THis is pretty much the Url.Host part only, as this came throug hthe request.
这几乎只是Url.Host部分,因为这是通过请求。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.