一个Asp.net探针的源码_[Asp.Net教程]
					现在针对Asp.net的探针很少,所以闲来无事就简单的写了一个,读取的信息如下 
服务器基本信息 
服务器计算机名 http://localhost/ 
服务器IP地址 127.0.0.1 
服务器域名 localhost 
服务器端口 80 
服务器IIS版本 Microsoft-IIS/6.0 
本文件所在文件夹 E:\downCode\ServerInfo\ 
服务器操作系统 Microsoft Windows NT 5.2.3790 Service Pack 1 
系统所在文件夹 C:\WINDOWS\system32 
服务器脚本超时时间 30000秒 
服务器的语言种类 Chinese (People's Republic of China) 
.NET Framework 版本 2.050727.42 
服务器当前时间 2007-5-25 9:32:55 
服务器IE版本 7.0000 
服务器上次启动到现在已运行 66分钟 
逻辑驱动器 A:\C:\D:\E:\F:\G:\H:\I:\ 
CPU 总数 2 
CPU 类型 x86 Family 15 Model 3 Stepping 4, GenuineIntel 
虚拟内存 61784M 
当前程序占用内存 6.44M 
Asp.net所占内存 60.46M 
Asp.net所占CPU 4 
当前Session数量 0 
当前SessionID gp3n1u55f2qcse55xo3q2x45 
当前系统用户名 NETWORK SERVICE 
由于还不是很成熟,所以暂时开源供大家讨论,希望能得到高手的补充!暂定版本0.90 
以下是源码部分 
复制C#代码保存代码
/// 
/// Asp.net服务器探针,Power by 51aspx.com
/// 作者liudao,51aspx.com版权所有 转载请保留版权信息
/// 
public partial class _Default : System.Web.UI.Page
{
 protected void Page_Load(object sender, EventArgs e)
 {
 if (!IsPostBack)
 {
 /// 
 /// 取应用程序路径
 /// 
 lbServerName.Text = "http://" + HttpContext.Current.Request.Url.Host + HttpContext.Current.Request.ApplicationPath;
 lbIp.Text = Request.ServerVariables["LOCAl_ADDR"];
 lbDomain.Text = Request.ServerVariables["SERVER_NAME"].ToString();
 lbPort.Text = Request.ServerVariables["Server_Port"].ToString();
 lbIISVer.Text = Request.ServerVariables["Server_SoftWare"].ToString();
 lbPhPath.Text = Request.PhysicalApplicationPath;
 lbOperat.Text = Environment.OSVersion.ToString();
 lbSystemPath.Text = Environment.SystemDirectory.ToString();
 lbTimeOut.Text = (Server.ScriptTimeout / 1000).ToString() + "秒";
 lbLan.Text = CultureInfo.InstalledUICulture.EnglishName;
 lbAspnetVer.Text = string.Concat(new object[] { Environment.Version.Major, ".", Environment.Version.Minor, Environment.Version.Build, ".", Environment.Version.Revision });
 lbCurrentTime.Text = DateTime.Now.ToString();
 RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Internet Explorer\Version Vector");
 lbIEVer.Text = key.GetValue("IE", "未检测到").ToString();
 lbServerLastStartToNow.Text = ((Environment.TickCount / 0x3e8) / 60).ToString() + "分钟";
 string[] achDrives = Directory.GetLogicalDrives();
 for (int i = 0; i < Directory.GetLogicalDrives().Length - 1; i++)
 {
 lbLogicDriver.Text = lbLogicDriver.Text + achDrives[i].ToString();
 }
 //ManagementClass diskClass = new ManagementClass("NUMBER_OF_PROCESSORS");
 lbCpuNum.Text = Environment.GetEnvironmentVariable("NUMBER_OF_PROCESSORS").ToString();
 lbCpuType.Text = Environment.GetEnvironmentVariable("PROCESSOR_IDENTIFIER").ToString();
 lbMemory.Text = (Environment.WorkingSet / 1024).ToString() + "M";
 lbMemoryPro.Text = ((Double) GC.GetTotalMemory(false) / 1048576).ToString("N2") + "M";
 lbMemoryNet.Text = ((Double) Process.GetCurrentProcess().WorkingSet64 / 1048576).ToString("N2") + "M";
 lbCpuNet.Text = ((TimeSpan) Process.GetCurrentProcess().TotalProcessorTime).TotalSeconds.ToString("N0");
 lbSessionNum.Text = Session.Contents.Count.ToString();
 lbSession.Text = Session.Contents.SessionID;
 lbUser.Text = Environment.UserName;
 }
 }
}
注意:当前版本只支持Asp.net2.0环境 
另外根据大家的补充版本不断升级中,敬请关注! 
作者liudao 
51aspx.com版权所有 转载请保留版权信息 
另外提供完整项目源码供大家下载,见笑了! 
http://www.51aspx.com/CV/AspNetTanZhen/