1. I Want to know currently how many active user access my asp.net page and now still there session is active or not .
2. At a time only any four users can access my perticular page .If fifth user trying to access same page it should provide a error massage " maximum Number of user Reached You cant be access this page right now ".
Rahul RudrakanthwarPosted Aug 11, 2015, 6:06 AM
Rahul BansalPosted Aug 11, 2015, 5:46 AM
Rahul RudrakanthwarPosted Aug 11, 2015, 5:43 AM
Upendra Pratap ShahiPosted Aug 11, 2015, 5:25 AM
void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
Application["OnlineUsers"] = 0;
}
void Session_Start(object sender, EventArgs e)
{
// Code that runs when a new session is started
Application.Lock();
Application["OnlineUsers"] = (int)Application["OnlineUsers"] + 1;
Application.UnLock();
}
void Session_End(object sender, EventArgs e)
{
// Code that runs when a session ends.
// Note: The Session_End event is raised only when the sessionstate mode
// is set to InProc in the Web.config file. If session mode is set to StateServer
// or SQLServer, the event is not raised.
Application["OnlineUsers"] = (int)Application["OnlineUsers"] - 1;
Application.UnLock();
}
Rahul BansalPosted Aug 11, 2015, 5:15 AM
{
// Code that runs on application startup
Application["OnlineUsers"] = 0;
}
{
// Code that runs when a new session is started
Application.Lock();
Application["OnlineUsers"] = (int)Application["OnlineUsers"] + 1;
Application.UnLock();
}
{
// Code that runs when a session ends.
// Note: The Session_End event is raised only when the sessionstate mode
// is set to InProc in the Web.config file. If session mode is set to StateServer
// or SQLServer, the event is not raised.
Application["OnlineUsers"] = (int)Application["OnlineUsers"] - 1;
Application.UnLock();
}