Search code examples
c#asp.netip-addressweb-farm

Environment.MachineName and IP address in a web farm in ASP.Net


  1. 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;

  2. 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();


Solution

  • The answers to these questions will depend on your hosting environment. The fastest way to find out is probably to try it.