I have a about 10 application variable counters in Global.asax for displaying the file downloads of these different 10 categories. Now I want to insert/Update values of these counters on a specific time (due to reset of counter when application restart get reset the counter) say at 11PM each day and update the counter.
How to do? Any ideas?
In Global.asax:
void Application_Start(object sender, EventArgs e)
{
Application.Add("MGM",0);
Application.Add("PC",0);
Application.Add("NC",0);
Application.Add("TC",0);
Application.Add("PGC",0);
}
The shortCode parameter is the name of global session from Global.asax file. That I am passing to get the counter and increment accordingly.
In Download.aspx.cs page:
private int GetCount(string shordCode)
{
int count=0;
count = Convert.ToInt32(Application[shortCode]);
lock (Application[shortCode])
{
Application[shortCode] = ++count;
}
return count;
}
Help appreciated..!
You Can use below code.