How to get a DNS name in a load balancing environment?

I have 4 servers participating in a load balancing environment. The same ASP.NET application is hosted on each server. I would like to get the DNS name no matter what server the server is on. Which of the following answers will give the correct answer?

Request.Url.Host
Environment.MachineName
System.Net.Dns.GetHostName() 

Thank you for your offer!

+3
source share
2 answers

You can try it Request.Url.GetLeftPart(UriPartial.Authority). So, for example, if the request URL http://www.contoso.com/index.htm?date=today, it will return http://www.contoso.com.

+3
source

The first. In fact, it is ONLY one that is even vaguely relevant.

  • Environment.MachineName can be anything you want - no one says it should be open via DNS. Especially in a hosting environment.
  • System.Net.Dns.GetHostName - , , .

Anyhjoe, , . Url.Host, .

0

All Articles