Reputation: 476
string ipname;
string strHostName = Dns.GetHostName();
IPHostEntry ipEntry = Dns.GetHostEntry(strHostName);
ipname = Convert.ToString(ipEntry.AddressList[1]);
string cleanIP = ipname.Replace(".", string.Empty);
string ipnew = cleanIP.Substring(6);
string full_app_code = DateTime.Now.ToString("yyyymmddhhmmss", System.Globalization.CultureInfo.GetCultureInfo("en-US")) + ipnew + "H";
My result for "full_app_code" work fine when run in localhost, full_app_code ="201632221032461247H", why when i try to generate the full_app_code in production server it fail to generate, the output i get is ="20161823091804389d:2895:83f2:d3e2%17H"
Upvotes: 1
Views: 53
Reputation: 476
add this (using System.Net.Sockets;
)
var ipHostEntry = Dns.GetHostEntry(Dns.GetHostName());
var ipAddressOfMachine = ipHostEntry.AddressList.FirstOrDefault(addressListItem => addressListItem.AddressFamily == AddressFamily.InterNetwork);
Upvotes: 1