Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Application_Start(object sender, EventArgs e)
- {
- Application["ActiveSessions"] = 0;
- }
- void Session_Start(object sender, EventArgs e)
- {
- try
- {
- Application.Lock();
- int activeSessions = (int) Application["ActiveSessions"] + 1;
- int allowedSessions = 10; // retrieve the threshold here instead
- Application["ActiveSessions"] = activeSessions;
- if (activeSessions > allowedSessions)
- System.Web.HttpContext.Current.Response.Redirect("~/UserLimitReached.aspx", false);
- }
- finally
- {
- Application.UnLock();
- }
- }
- void Session_End(object sender, EventArgs e)
- {
- Application.Lock();
- Application["ActiveSessions"] = (int)Application["ActiveSessions"] - 1;
- Application.UnLock();
- }
Add Comment
Please, Sign In to add comment