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 BansalRank #143 · 15.9K reputationPosted Aug 11, 2015, 1:15 AM EDT
{
// 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();
}
Upendra Pratap ShahiRank #329 · 7.5K reputationPosted Aug 11, 2015, 1:25 AM EDT
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 Rudrakanthwar5 reputationPosted Aug 11, 2015, 1:43 AM EDT
Rahul BansalRank #143 · 15.9K reputationPosted Aug 11, 2015, 1:46 AM EDT
Rahul Rudrakanthwar5 reputationPosted Aug 11, 2015, 2:06 AM EDT