The function below is used to get the IP Address of Server. The System.Net
namespace is needed for this function. This is because IPHostEntry
and IPAddress
are class in System.Net
namespace. Beside this, GetHostName()
function also belong to System.Net.Dns
.
public string GetIPAddress()
{
string strHostName = System.Net.Dns.GetHostName(); IPHostEntry ipHostInfo = Dns.Resolve(Dns.GetHostName()); IPAddress ipAddress = ipHostInfo.AddressList[0]; return ipAddress.ToString();
}
Monday, March 10, 2008
Gets IP Address of Server PC using C# (ASP .NET 1.1)
Posted by Wec at 11:39:00 AM
Labels: .NET Programming, ASP .NET 1.1, C#.NET
Subscribe to:
Post Comments (Atom)
1 comments:
great code
Post a Comment