IP address and hostname Fetch in ASPX.NET

COMMAND [CODE BEHIND FILE]

[1] Retrieve IP ADDRESS

        string ip = Request.UserHostAddress;

OUTPUT:

10.4.136.215

[2] Retrieve PC HOSTNAME

IP Address to be used to get hostname of the user PC.

 var hostEntry = Dns.GetHostEntry(ip);

OUTPUT:

aspirant.manoj@gmail.com

For Extra Information

Leave a Comment