badpagecounter.aspx

来自「asp.net技术内幕的书配源码」· ASPX 代码 · 共 37 行

ASPX
37 行
字号
<%@ Page Language="C#" %>
<script language="C#" runat=server>
  
void Page_Load(Object sender , EventArgs e) 
{
	if(null == Application["PageCounter"])
	{
		Application.Lock();
		Application["PageCounter"] = 0;
		Application.UnLock();
	}
	int aHits = 0;
	int nHits = (int) Application["PageCounter"];
	aHits = (int)aHits + 1;
	Application.Lock();
	Application["PageCounter"] = aHits;
	lblCount.Text = Application[ "PageCounter" ].ToString();
	//lblCount.Text["PageCounter"] = aHits;
	Application.UnLock();
}



</Script>

<html>
<head><title>GoodPageCounter.aspx</title></head>
<body>

This page has been requested:
<asp:Label
  ID="lblCount"
  Runat="Server" />
times!

</body>
</html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?