Javad.Kashi
دوشنبه 06 تیر 1390, 13:53 عصر
سلام
من در سایتم برای بدست آوردن بازدید ها و تعداد کاربران آنلاین در Global.asax این کد ها را نوشتم:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;
namespace Project
{
public class Global : System.Web.HttpApplication
{
// These two properties are used for statistics purposes.
private static int _TotalNumberOfVisits = 0;
private static int _NumberOfOnlineUsers = 0;
//------------------------------------------------------
protected void Session_Start(object sender, EventArgs e)
{
_TotalNumberOfVisits += 1;
_NumberOfOnlineUsers += 1;
}
protected void Session_End(object sender, EventArgs e)
{
_NumberOfOnlineUsers -= 1;
}
//----------------------------------------------------
/// <summary>
/// This Property Only returns the total number of all visits occure since the application has started.
/// </summary>
public static int TotalNumberOfVisits
{
get
{
return _TotalNumberOfVisits;
}
}
/// <summary>
/// This Property Only returns the number of online users in the application.
/// </summary>
public static int NumberOfOnlineUsers
{
get
{
return _NumberOfOnlineUsers;
}
}
}
}
ولی بعدا متوجه شدم که هر روز تعداد بازدید ها به 0 برمی گردد.:متعجب:
1. چرا این اتفاق می افتد؟
2. پیشنهاد شما در مورد جابه جایی این property و فیلد پیشتیبان آن به کالکشن []Application چیست؟
یا علی
من در سایتم برای بدست آوردن بازدید ها و تعداد کاربران آنلاین در Global.asax این کد ها را نوشتم:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;
namespace Project
{
public class Global : System.Web.HttpApplication
{
// These two properties are used for statistics purposes.
private static int _TotalNumberOfVisits = 0;
private static int _NumberOfOnlineUsers = 0;
//------------------------------------------------------
protected void Session_Start(object sender, EventArgs e)
{
_TotalNumberOfVisits += 1;
_NumberOfOnlineUsers += 1;
}
protected void Session_End(object sender, EventArgs e)
{
_NumberOfOnlineUsers -= 1;
}
//----------------------------------------------------
/// <summary>
/// This Property Only returns the total number of all visits occure since the application has started.
/// </summary>
public static int TotalNumberOfVisits
{
get
{
return _TotalNumberOfVisits;
}
}
/// <summary>
/// This Property Only returns the number of online users in the application.
/// </summary>
public static int NumberOfOnlineUsers
{
get
{
return _NumberOfOnlineUsers;
}
}
}
}
ولی بعدا متوجه شدم که هر روز تعداد بازدید ها به 0 برمی گردد.:متعجب:
1. چرا این اتفاق می افتد؟
2. پیشنهاد شما در مورد جابه جایی این property و فیلد پیشتیبان آن به کالکشن []Application چیست؟
یا علی