Showing posts with label Client Host Name. Show all posts
Showing posts with label Client Host Name. Show all posts

Tuesday, August 25, 2009

ASP.NET Client IP address, Client Host Name, visitor's browser type etc.

ASP.NET Client IP address, Client Host Name, visitor's browser type etc.
This example demonstrates how to find out the visitor's browser type, IP address, and more:

<html>
<body>
<p>
<b>You are browsing this site with:</b>
<%Response.Write(Request.ServerVariables("http_user_agent"))%>
</p>
<p>
<b>Your IP address is:</b>
<%Response.Write(Request.ServerVariables("remote_addr"))%>
</p>
<p>
<b>The DNS lookup of the IP address is:</b>
<%Response.Write(Request.ServerVariables("remote_host"))%>
</p>
<p>
<b>The method used to call the page:</b>
<%Response.Write(Request.ServerVariables("request_method"))%>
</p>
<p>
<b>The server's domain name:</b>
<%Response.Write(Request.ServerVariables("server_name"))%>
</p>
<p>
<b>The server's port:</b>
<%Response.Write(Request.ServerVariables("server_port"))%>
</p>
<p>
<b>The server's software:</b>
<%Response.Write(Request.ServerVariables("server_software"))%>
</p>
</body>
</html>

Friday, July 11, 2008

Getting Client Host name using Java Script/C#

Getting Client Host name using Java Script

function GetComputerName()
{
try
{
var WshNetwork = new ActiveXObject("WScript.Network");
var hostname = WshNetwork.ComputerName.toLowerCase(); document.getElementById('HdnMachineId').value = hostname;
}
catch(err)
{ }
}

Getting Client Host name using C#

private string getClientHostName()
{
// Get HostName of client computer
string hostname = HttpContext.Current.Request.ServerVariables["REMOTE_HOST"].ToString().ToLower();
try
{
System.Net.IPHostEntry host = System.Net.Dns.GetHostByAddress(hostname);
hostname = host.HostName;
}
catch(Exception exp)
{

}
return hostname;
}