I am working on a MVC website, and I want to know the number of user visits my website has.
I am using below code in Application_Start()
in global.asax.cs
:
protected void Application_Start()
{
Application["Totaluser"] = 0;
AreaRegistration.RegisterAllAreas();
WebApiConfig.Register(GlobalConfiguration.Configuration);
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
}
protected void Session_Start()
{
Application.Lock();
Application["Totaluser"] = (int)(Application["TotalUser"] + 1);
Application.Unlock();
}
But when I am opening the website freshly, it is showing as 1
all the time.
How do I maintain the count all the time, so that it will show the number of hits correctly?