日期:2014-05-19  浏览次数:20884 次

如何获得web访问者的计算机名啊?
如何获得web访问者的计算机名啊
再次发帖子,请高手指点!

------解决方案--------------------
参考下如下的代码:
private string getIp()
{/*穿过代理服务器取远程用户真实IP地址:*/
if (Request.ServerVariables[ "HTTP_VIA "] != null)
return Request.ServerVariables[ "HTTP_X_FORWARDED_FOR "].ToString();
else
return Request.ServerVariables[ "REMOTE_ADDR "].ToString();
}


Label2.Text = getIp();
HttpBrowserCapabilities bc = new HttpBrowserCapabilities();
bc = Request.Browser;
string xitong = "你的操作系统为 ";
Label3.Text = xitong + bc.Platform + " 浏览器类型: " + bc.Type;

------解决方案--------------------
Web客户端权限太低,考虑安全性因素,不能获得计算机名吧,要不就自己写ActiveX插件...


下面有篇文章介绍Http头
http://msdn.microsoft.com/library/chs/default.asp?url=/library/CHS/act/htm/actml_ref_href.asp
------解决方案--------------------
#region 客户端信息相关
#region 获取客户IP
public static string getUserIp()
{
return HttpContext.Current.Request.UserHostAddress;
}

/// <summary>
/// 猎取客户端IP地址
/// </summary>
/// <param name= "page "> 调用该方法的页面 </param>
/// <returns> 返回的IP地址字符串 </returns>
public static string GetClientIP(System.Web.UI.Page page)
{
string ipAddress = " ";
if (HttpContext.Current.Request.ServerVariables[ "HTTP_X_FORWARDED_FOR "] == null)
{
ipAddress = HttpContext.Current.Request.ServerVariables[ "Remote_Addr "];
}
else
{
ipAddress = HttpContext.Current.Request.ServerVariables[ "HTTP_X_FORWARDED_FOR "];
}
return ipAddress;
}
#endregion

#region 获取客户电脑名
public static string getUserHostName()
{
return HttpContext.Current.Server.MachineName.ToString();
}
#endregion
#endregion
------解决方案--------------------
以前做1.1的项目的时候,用过这种方法,2.0没测试

首先取得用户IP地址,然后

利用System.Net:

IPHostEntry hostInfo = Dns.GetHostByAddress( "IP地址 ");
Response.Write(hostInfo.HostName.ToString());