ここをクリック 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; } }
}
}
Global.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>
Global.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で、エラーヒットカウンターを取得することは現在のコンテキストに存在しません