http://www.asp888.net 豆腐技术站
这个是我在国外的一个站点上看到的使用Asp.Net得到一些系统变量的程序,
大家可以看看,其实这个程序没有多大的用处,只是说明一下asp.Net 的强大功能而已。
1<script language="C#" runat="server">
2void Page_Load(Object sender, EventArgs ev)
3{
4ProcessInfo[] history = ProcessModelInfo.GetHistory(100);
5for( int i=0; i<history.Length; i++ )
6{
7Response.Write("StartTime:"+ history[i].StartTime.ToString() + "<BR>");
8Response.Write("Age:" + history[i].Age.ToString() + "<BR>");
9Response.Write("ProcessID:" + history[i].ProcessID.ToString() + "<BR>");
10Response.Write("RequestCount:" + history[i].RequestCount.ToString() + "<BR>");
11Response.Write("Status:" + GetProcessStatus(history[i].Status ) + "<BR>");
12Response.Write("ShutdownReason:" + GetShutdownReason(history[i].ShutdownReason) + "<BR>");
13Response.Write("PeakMemoryUsed:" + history[i].PeakMemoryUsed.ToString() + "<BR>");
14
15}
16}
17
18public String GetProcessStatus( ProcessStatus ps )
19{
20String s = "Unknown";
21if( ps == ProcessStatus.Alive )
22s = "Alive";
23else if( ps == ProcessStatus.ShuttingDown )
24s = "Shutting Down";
25else if( ps == ProcessStatus.ShutDown )
26s = "Shutdown";
27else if( ps == ProcessStatus.Terminated )
28s = "Terminated";
29return s;
30}
31
32public String GetShutdownReason( ProcessShutdownReason psr )
33{
34String s = "Unknown";
35if( psr == ProcessShutdownReason.None )
36s = "N/A";
37else if( psr == ProcessShutdownReason.Unexpected )
38s = "Unexpected";
39else if( psr == ProcessShutdownReason.RequestsLimit )
40s = "Requests Limit";
41else if( psr == ProcessShutdownReason.RequestQueueLimit )
42s = "Request Queue Limit";
43else if( psr == ProcessShutdownReason.Timeout )
44s = "Timeout";
45else if( psr == ProcessShutdownReason.IdleTimeout )
46s = "Idle Timeout";
47else if( psr == ProcessShutdownReason.MemoryLimitExceeded )
48s = "Memory Limit Exceeded";
49return s;
50}
51</script>