📄 readcounters.aspx
字号:
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Diagnostics" %>
<script language="C#" runat=server>
void Page_Load(Object sender , EventArgs e)
{
if (! IsPostBack ) {
PerformanceCounterCategory objCategory;
objCategory = new PerformanceCounterCategory( "ASP.NET Applications" );
lstInstances.DataSource = objCategory.GetInstanceNames();
DataBind();
}
}
void SelectInstance( object s, EventArgs e ) {
PerformanceCounterCategory objCategory;
objCategory = new PerformanceCounterCategory( "ASP.NET Applications" );
lstCounters.Visible = true;
lstCounters.DataSource = objCategory.GetCounters( lstInstances.SelectedItem.Text );
lstCounters.DataTextField = "CounterName";
DataBind();
}
void SelectCounter( object s, EventArgs e ) {
PerformanceCounter objCounter;
objCounter = new PerformanceCounter( "ASP.NET Applications", lstCounters.SelectedItem.Text, lstInstances.SelectedItem.Text );
lblValue.Text = objCounter.NextValue().ToString();
}
</Script>
<html>
<head><title>ReadCounters.aspx</title></head>
<body>
<h2>ASP.NET Application Performance Counters</h2>
<form Runat="Server">
<b>Instances</b>
<br>
<asp:ListBox
ID="lstInstances"
AutoPostback="True"
OnSelectedIndexChanged="SelectInstance"
Runat="Server" />
<p>
<b>Counters</b>
<br>
<asp:ListBox
ID="lstCounters"
Visible="False"
AutoPostback="True"
OnSelectedIndexChanged="SelectCounter"
Runat="Server" />
<p>
<b>Counter Value:</b>
<asp:Label
ID="lblValue"
Runat="Server" />
</form>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -