sashaeve
sashaeve

Reputation: 9617

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

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?

Upvotes: 3

Views: 6012

Answers (3)

Raj Chaurasia
Raj Chaurasia

Reputation: 1974

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

Upvotes: -1

CodingInsomnia
CodingInsomnia

Reputation: 1863

Perhaps Server.MachineName does what you are looking for?

Upvotes: 1

kbrimington
kbrimington

Reputation: 25692

Try System.Environment.MachineName.

Upvotes: 10

Related Questions