如何在负载均衡环境中获取DNS名称?
我有 4 台服务器参与负载平衡环境。每台服务器上都托管着相同的 ASP.NET 应用程序。 无论底层服务器如何,我都想获取 DNS 名称。 以下哪一项将给出正确答案?
Request.Url.Host
Environment.MachineName
System.Net.Dns.GetHostName()
感谢您的建议!
I have 4 servers participating in load balancing environment. The same ASP.NET application is being hosted in each server.
I would like to get the DNS Name regardless of the underlying server.
Which one of the followings will give the correct answer?
Request.Url.Host
Environment.MachineName
System.Net.Dns.GetHostName()
Thanks for your suggestion!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以尝试
Request.Url.GetLeftPart(UriPartial.Authority)
。例如,如果请求 URL 为http://www.contoso.com/index.htm?date=today
,则将返回http://www.contoso.com
>。You could try
Request.Url.GetLeftPart(UriPartial.Authority)
. So for example if the request url ishttp://www.contoso.com/index.htm?date=today
this will returnhttp://www.contoso.com
.第一个。它实际上是唯一一个模糊相关的。
Anyhjoe,我的都不是用来访问机器的。这几乎只是 Url.Host 部分,因为这是通过请求实现的。
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. THis is pretty much the Url.Host part only, as this came throug hthe request.