Will the following line of code always return a unique machine name in a web farm, or it could sometimes return nothing/duplicate name?
string currentRequestWebFarmNode = Environment.MachineName;
Also, is IP address for each web farm node obtained by using code below going to be unique always in that web farm? My guess is yes, but not sure.
string currentRequestWebFarmNode = System.Net.Dns.GetHostEntry(Request.Url.Host).AddressList(0).ToString();
Asked
Active
Viewed 1,010 times
0

Sunil
- 20,653
- 28
- 112
- 197
1 Answers
1
The answers to these questions will depend on your hosting environment. The fastest way to find out is probably to try it.

j__m
- 9,392
- 1
- 32
- 56
-
I was looking for a fool-proof way of obtaining a 'unique' value for either IP address or machine name in a web farm. You think that may not be possible? – Sunil Nov 28 '13 at 23:49
-
I actually strongly suspect that it is possible. I just can't tell you what either of those expressions will return because it's based on how those machines are configured. – j__m Nov 28 '13 at 23:53
-
Ok. FYI - I was developing a generic framework where I needed to get a unique name for the current request's web server. That means my code will have to work in all web farms. – Sunil Nov 29 '13 at 00:00
-
Environment.MachineName seems like a reasonable name, but there's no way to guarantee uniqueness. – j__m Nov 29 '13 at 00:03