ResolveIP Method (.NET)

 

Returns: A string representing the host name for the IP address, or a null value if the IP address cannot be resolved via a reverse DNS lookup.

 

Syntax:

 string hostname = browObj.ResolveIP();

 string hostname = BrowserObj.ResolveIP(string ipAddr);

 string hostname = BrowserObj.ResolveIP(IPAddress ipAddr);

 

ipAddr provides the IP address to resolve to a host name. This can either be an IP address in the form of a string, such as "207.46.249.190" or in the form of the .NET IPAddress class.

 

The ResolveIP method is used to perform reverse DNS look-ups. This method is available as both a static member of the BrowserObj class, as well as an instance member.

 

The instance member ResolveIP method performs the lookup on the value in the IPAddr property of the BrowserHawk object, which is set automatically to the IP address of the visitor when using the object under ASP.NET and the GetBrowser() method is called. This form of ResolveIP should be used to perform a reverse DNS lookup for the current visitor.

 

The static member function form of the ResolveIP method is similar to the instance member function version, except that it takes an IP address as an argument. This enables you to perform a reverse DNS lookup for any IP address you specify. If using BrowserHawk from outside the context of an ASP.NET page, this static method must be used.

 

C# Example – Reverse DNS lookup for current site visitor:

<html>

<% BrowserObj browObj = BrowserObj.GetBrowser();

string hostn = browObj.ResolveIP();

if (hostn == null) {

hostn = "Not available";

}

Response.Write("Host name for IP address: " + browObj.IPAddr + " is: " + hostn);

%>

</html>

 

C# Example – Reverse DNS lookup for a specific IP address:

<html>

<%

string hostn = BrowserObj.ResolveIP("207.46.249.190");

if (hostn == null) {

hostn = "Not available";

}

Response.Write("Host name for IP address 207.46.249.190 is: " + hostn);

%>

</html>

 

See Also:

IPAddr Property (.NET)