显示结果如下:
IP地址:127.0.0.1
域名:localhost
端口:1435
本文件所在路径:E:\myaspx\探针\
操作系统:Microsoft Windows NT 5.1.2600 Service Pack 2
操作系统所在文件夹:C:\WINDOWS\system32
脚本超时时间:0秒系统语言:Chinese (People's Republic of China)
.NET版本:2.050727.42
IE版本:6.0000
启动到现在已运行:111分钟
逻辑驱动器:C:\D:\E:\F:\G:\H:\
CPU 数量:2
CPU类型:x86 Family 15 Model 6 Stepping 5, GenuineIntel
ASP.NET所站内存:31.60M
ASP.NET所占CPU:3%
当前系统用户名:nan
代码如下(可直接复制到.aspx文件中使用):
<%@ Page Language="C#"%>
<%@ Import Namespace="System.Globalization"%>
<%@ Import Namespace="Microsoft.Win32" %>
<%@ Import Namespace="System.IO"%>
<%@ Import Namespace="System.Diagnostics" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>asp.net 探针</title>
<style type="text/css">
body{font:12px tahoma;line-height:28px;background:black;color:white}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<%
//代码多有参考网络,可把代码直接复制到任何页面直接使用,代码为我所用,非我所想
Response.Write("计算机名:");
Response.Write("http://" + HttpContext.Current.Request.Url.Host + HttpContext.Current.Request.ApplicationPath + "<br />");
Response.Write("IP地址:");
Response.Write(Request.ServerVariables["LOCAl_ADDR"] + "<br />");
Response.Write("域名:");
Response.Write(Request.ServerVariables["SERVER_NAME"].ToString() + "<br />");
Response.Write("端口:");
Response.Write(Request.ServerVariables["Server_Port"].ToString() + "<br />");
Response.Write("本文件所在路径:");
Response.Write(Request.PhysicalApplicationPath + "<br />");
Response.Write("操作系统:");
Response.Write(Environment.OSVersion.ToString() + "<br />");
Response.Write("操作系统所在文件夹:");
Response.Write(Environment.SystemDirectory.ToString() + "<br />");
Response.Write("脚本超时时间:");
Response.Write((Server.ScriptTimeout / 1000).ToString() + "秒" + "<br />");
Response.Write("系统语言:");
Response.Write(CultureInfo.InstalledUICulture.EnglishName + "<br />");
Response.Write(".NET版本:");
Response.Write(string.Concat(new object[] { Environment.Version.Major, ".", Environment.Version.Minor, Environment.Version.Build, ".", Environment.Version.Revision }) + "<br />");
Response.Write("IE版本:");
RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Internet Explorer\Version Vector");
Response.Write(key.GetValue("IE", "未检测到").ToString() + "<br />");
Response.Write("启动到现在已运行:");
Response.Write(((Environment.TickCount / 0x3e8) / 60).ToString() + "分钟" + "<br />");
Response.Write("逻辑驱动器:");
string[] achDrives = Directory.GetLogicalDrives();
for (int i = 0; i < Directory.GetLogicalDrives().Length - 1; i++)
{
Response.Write(achDrives[i].ToString());
}
Response.Write("<br />");
Response.Write("CPU 数量:");
Response.Write(Environment.GetEnvironmentVariable("NUMBER_OF_PROCESSORS").ToString() + "<br />");
Response.Write("CPU类型:");
Response.Write(Environment.GetEnvironmentVariable("PROCESSOR_IDENTIFIER").ToString() + "<br />");
Response.Write("ASP.NET所站内存:");
Response.Write(((Double)Process.GetCurrentProcess().WorkingSet64 / 1048576).ToString("N2") + "M" + "<br />");
Response.Write("ASP.NET所占CPU:");
Response.Write(((TimeSpan)Process.GetCurrentProcess().TotalProcessorTime).TotalSeconds.ToString("N0") + "%<br />");
Response.Write("当前系统用户名:");
Response.Write(Environment.UserName + "<br />");
%>
</div>
</form>
</body>
</html>