ASP.NET获取客户端、服务器端基础信息

1. 在ASP.NET中专用属性:
获取服务器电脑名:Page.Server.ManchineName
获取用户信息:Page.User
获取客户端电脑名:Page.Request.UserHostName
获取客户端电脑IP:Page.Request.UserHostAddress
 
2. 在网络编程中的通用方法:
获取当前电脑名:static System.Net.Dns.GetHostName()
根据电脑名取出全部IP地址:static System.Net.Dns.Resolve(电脑名).AddressList
也可根据IP地址取出电脑名:static System.Net.Dns.Resolve(IP地址).HostName
 
3. 系统环境类的通用属性:
当前电脑名:static System.Environment.MachineName
当前电脑所属网域:static System.Environment.UserDomainName
当前电脑用户:static System.Environment.UserName
  
 
客户端IP:Page.Request.UserHostAddress;
用户信息:Page.User;
服务器电脑名称:Page.Server.MachineName;
当前用户电脑名称:System.Net.Dns.GetHostName();
当前电脑名:System.Environment.MachineName;
当前电脑所属网域:System.Environment.UserDomainName;
当前电脑用户:System.Environment.UserName;
浏览器类型:Request.Browser.Browser;
浏览器标识:Request.Browser.Id;
浏览器版本号:Request.Browser.Version;
浏览器是不是测试版本:Request.Browser.Beta;
浏览器的分辨率(像素):Request[ "width" ].ToString() + "*"  + Request[ "height" ].ToString();//1280*1024
客户端的操作系统:Request.Browser.Platform;
是不是win16系统:Request.Browser.Win16;
是不是win32系统:Request.Browser.Win32;
 
 
服务器端的信息:
 
服务器计算机名: "http://" + HttpContext.Current.Request.Url.Host + HttpContext.Current.Request.ApplicationPath;
 
服务器IIS版本: Request.ServerVariables[ "Server_SoftWare" ].ToString();
 
服务器域名:Request.ServerVariables[ "SERVER_NAME" ].ToString();
 
服务器端口:Request.ServerVariables[ "Server_Port" ].ToString();
 
服务器IP地址:Request.ServerVariables[ "LOCAl_ADDR" ]
 
服务器脚本超时时间:(Server.ScriptTimeout / 1000).ToString() + "秒" ;
 
服务器操作系统:Environment.OSVersion.ToString();
 
本文件所在文件夹:Request.PhysicalApplicationPath;
 
服务器IE版本:Registry.LocalMachine.OpenSubKey(@ "SOFTWARE/Microsoft/Internet Explorer/Version Vector" ).GetValue( "IE" , "未检测到" ).ToString();
 
系统所在文件夹:Environment.SystemDirectory.ToString();
 
服务器当前时间: DateTime.Now.ToString();
 
服务器的语言种类:CultureInfo.InstalledUICulture.EnglishName;
 
服务器上次启动到现在已运行时间: ((Environment.TickCount / 0x3e8) / 60).ToString() + "分钟" ;
 
CPU 类型:Environment.GetEnvironmentVariable( "PROCESSOR_IDENTIFIER" ).ToString();
 
逻辑驱动器:string[] achDrives = Directory.GetLogicalDrives();
for (int i = 0; i < Directory.GetLogicalDrives().Length - 1; i++)
{
    achDrives[i].ToString();
}
 
CPU 总数:Environment.GetEnvironmentVariable( "NUMBER_OF_PROCESSORS" ).ToString();
 
虚拟内存:(Environment.WorkingSet / 1024).ToString() + "M" ;
 
.NET Framework 版本:string.Concat(new object[] { Environment.Version.Major, "." , Environment.Version.Minor, Environment.Version.Build, "." , Environment.Version.Revision });
 
Asp.net所占CPU:((TimeSpan)Process.GetCurrentProcess().TotalProcessorTime).TotalSeconds.ToString( "N0" );
 
Asp.net所占内存: (( Double )Process.GetCurrentProcess().WorkingSet64 / 1048576).ToString( "N2" ) +  "M" ;
 
当前Session数量:Session.Contents.Count.ToString();
 
当前程序占用内存:(( Double )GC.GetTotalMemory(false) / 1048576).ToString( "N2" ) + "M" ;
 
当前SessionID:Session.Contents.SessionID;
 
当前系统用户名:Environment.UserName;

猜你喜欢

转载自www.cnblogs.com/asd14828/p/10508170.html