using System.Net; namespace GetClientIPAddress { class Program { static void Main(string[] args) { //GetHostByName(this parameter is what). IPAddress[] addresses = Dns.GetHostByName("").AddressList; //If only want IP. How to do that? Console.Write("Your IP Address is:"); foreach (IPAddress address in addresses) { Console.WriteLine(address.ToString()); } Console.ReadKey(true); } } }
Kenny Tangnde
01-Oct-2011Anonymous User
01-Oct-2011You can use following line of code to get machine name.
Console.WriteLine(Environment.MachineName);
Thanks.
Kenny Tangnde
01-Oct-2011Hi Awadhendra Tiwari,
How get the local computer name.
Thanks.
Kenny Tangnde
01-Oct-2011Hi Awadhendra Tiwari,
thanks for your helping.
Anonymous User
01-Oct-2011If you want to know client ip address in asp.net then you can use following code
Request.UserHostAddress() ---> It will give you client address
And if you want it in c# then you can write following code
IPAddress[] addresses = Dns.GetHostByName( "MACHINE1" ).AddressList;
foreach( IPAddress address in addresses )
{
Console.WriteLine( address.ToString() );
}
Thanks.
Kenny Tangnde
30-Sep-2011Consider the user's account unusual, such as remote login
Anonymous User
30-Sep-2011