单击此处 Global.asax.cs
namespace WebApplication7
{
public class Global : System.Web.HttpApplication
{
private static int countdays=0;
protected void Application_Start(object sender, EventArgs e)
{
countdays = 0;
}
protected void Session_Start(object sender, EventArgs e)
{
countdays += 1;
}
protected void Application_BeginRequest(object sender, EventArgs e)
{
}
protected void Application_AuthenticateRequest(object sender, EventArgs e)
{
}
protected void Application_Error(object sender, EventArgs e)
{
}
protected void Session_End(object sender, EventArgs e)
{
countdays -= 1;
}
protected void Application_End(object sender, EventArgs e)
{
}
public static int CountNo { get { return countdays; } }
}
}
全球.apsx
<body>
<form id="fromHitCounter" method="post" runat="server">
Total number of days since the Web server started:
<asp:label id="lblCount" runat="server"></asp:label><br />
</form>
</body>
全局.aspx.cs
private void Page_Load(object sender, System.EventArgs e)
{
int Countdays = HitCounters.Global.Countdays;//Hit counter does not exist
lblCount.Text = Countdays.ToString();
}
如何使用 global.asax 文件计算 asp.net 中的天数计数器,在 Global.aspx.cs iam 中获取错误命中计数器在当前上下文中不存在