我已经找了很多种方法,只要上传到服务器上,要么得到是服务器机器名,要么就是得到客户端IP,没办法得到客户端的机器名
例如如下代码就不管用.
- C# code
//IP System.Net.IPAddress ip = System.Net.IPAddress.Parse(Request.UserHostAddress); System.Net.IPHostEntry ihe = Dns.GetHostEntry(ip); //机器名 string clientname = ihe.HostName; Response.Write("clientname: " + clientname); string info = ""; info += "<br/>当前用户电脑名称:" + System.Net.Dns.GetHostName(); info += "<br/>当前电脑名:" + System.Environment.MachineName; Response.Write(info);
------解决方案--------------------------------------------------------
- C# code
string info ="客户端IP:"+ Page.Request.UserHostAddress;info += "<br/>用户信息:" + Page.User;info += "<br/>服务器电脑名称:" + Page.Server.MachineName;info += "<br/>当前用户电脑名称:" + System.Net.Dns.GetHostName();info += "<br/>当前电脑名:" + System.Environment.MachineName;info += "<br/>当前电脑所属网域:" + System.Environment.UserDomainName;info += "<br/>当前电脑用户:" + System.Environment.UserName;info += "<br/>浏览器类型:"+Request.Browser.Browser;info += "<br/>浏览器标识:" + Request.Browser.Id;info += "<br/>浏览器版本号:" + Request.Browser.Version;info += "<br/>浏览器是不是测试版本:"+Request.Browser.Beta;info += "<br/>浏览器的分辨率(像素):" + Request["width"].ToString() + "*" + Request["height"].ToString();//1280/1024info += "<hr/>";info += "<br/>客户端的操作系统:"+Request.Browser.Platform;info += "<br/>是不是win16系统:"+Request.Browser.Win16;info += "<br/>是不是win32系统:" +Request.Browser.Win32;
------解决方案--------------------------------------------------------
2楼的已经很全了。楼主看看是不是你想要的。
------解决方案--------------------------------------------------------
IIS 设置中目录安全性>>>匿名访问和身份验证控制
------解决方案--------------------------------------------------------
呵呵,楼上根本没有。
------解决方案--------------------------------------------------------
关注,顶
------解决方案--------------------------------------------------------
二楼很强大
------解决方案--------------------------------------------------------
- C# code
// 将客户端的信息添加到 Dictionary 中 Dictionary<string, string> clientInfos = new Dictionary<string, string>(); try { string ip = Request.UserHostAddress; string userAgent = Request.UserAgent == null ? "无" : Request.UserAgent; clientInfos.Add("开发商", "*****有限公司"); clientInfos.Add("平台名称","**_CMS网站后台管理系统"); if (Request.ServerVariables["HTTP_UA_CPU"] == null) clientInfos.Add("CPU 类型", "未知"); else clientInfos.Add("CPU 类型", Request.ServerVariables["HTTP_UA_CPU"]); clientInfos.Add("操作系统", this.GetOSNameByUserAgent(userAgent)); clientInfos.Add("IP 地址", ip); if (Request.Browser.ClrVersion == null) clientInfos.Add(".NET CLR 版本", "不支持"); else clientInfos.Add(".NET CLR 版本", Request.Browser.ClrVersion.ToString()); clientInfos.Add("浏览器", Request.Browser.Browser + Request.Browser.Version); clientInfos.Add("支持 ActiveX", Request.Browser.ActiveXControls ? "支持" : "不支持"); clientInfos.Add("支持 Cookies", Request.Browser.Cookies ? "支持" : "不支持"); clientInfos.Add("支持 CSS", Request.Browser.SupportsCss ? "支持" : "不支持"); clientInfos.Add("语言", Request.UserLanguages[0]); string httpAccept = Request.ServerVariables["HTTP_ACCEPT"]; if (httpAccept == null) clientInfos.Add("计算机/手机", "未知"); else if (httpAccept.IndexOf("wap") > -1) clientInfos.Add("计算机/手机", "手机"); else clientInfos.Add("计算机/手机", "计算机"); clientInfos.Add("Platform", Request.Browser.Platform); clientInfos.Add("Win16", Request.Browser.Win16 ? "是" : "不是"); clientInfos.Add("Win32", Request.Browser.Win32 ? "是" : "不是"); if (Request.ServerVariables["HTTP_ACCEPT_ENCODING"] == null) clientInfos.Add("Http Accept Encoding", "无"); else clientInfos.Add("Http Accept Encoding", Request.ServerVariables["HTTP_ACCEPT_ENCODING"]); clientInfos.Add("User Agent", userAgent); } catch (Exception ex) { Response.Write(ex.Message); } // 根据 Dictionary 中的内容在 Table 中显示客户端信息 Response.Write(""); this.Response.Write("<table cellpadding=0 width='95%' cellspacing=0 class='table_southidc'>"); this.Response.Write("<tr>"); this.Response.Write("<td style='backcolor:#ecf5ff' width=145>项目</td>"); this.Response.Write("<td>值</td>"); this.Response.Write("</tr>"); foreach (string key in clientInfos.Keys) { this.Response.Write("<tr>"); this.Response.Write("<td>" + key + "</font></td>"); this.Response.Write("<td>" + clientInfos[key].ToString() + "</td>"); this.Response.Write("</tr>"); } this.Response.Write("</table>"); } /// <summary> /// 根据 User Agent 获取操作系统名称 /// </summary> private string GetOSNameByUserAgent(string userAgent) { string osVersion = "未知"; if (userAgent.Contains("NT 6.0")) { osVersion = "Windows Vista/Server 2008"; } else if (userAgent.Contains("NT 5.2")) { osVersion = "Windows Server 2003"; } else if (userAgent.Contains("NT 5.1")) { osVersion = "Windows XP"; } else if (userAgent.Contains("NT 5")) { osVersion = "Windows 2000"; } else if (userAgent.Contains("NT 4")) { osVersion = "Windows NT4"; } else if (userAgent.Contains("Me")) { osVersion = "Windows Me"; } else if (userAgent.Contains("98")) { osVersion = "Windows 98"; } else if (userAgent.Contains("95")) { osVersion = "Windows 95"; } else if (userAgent.Contains("Mac")) { osVersion = "Mac"; } else if (userAgent.Contains("Unix")) { osVersion = "UNIX"; } else if (userAgent.Contains("Linux")) { osVersion = "Linux"; } else if (userAgent.Contains("SunOS")) { osVersion = "SunOS"; } return osVersion; }