Restict Number of Connections......
Web Development
2
Posts
2
Posters
0
Views
1
Watching
-
-
My Problem is as I have one virtual directory hosted on our server. Now I, want only 10 users can access the virtual directory at any instance of time. The server we are running is windows 2003, IIS 6, ASP.net 2.0 How can i restrict the access
Try this
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();
}