Click here to Skip to main content
15,903,203 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i need to allow 100 users only to access my site, how ?

what r the web.config settings
Posted
Updated 25-May-12 0:58am
v4

1 solution

Write code in global.asax file which interacts with the entire application.
The sample code is given below:
C#
void Application_OnStart(Object Sender, EventArgs E)
{
       Application["CurrentUsers"] = 0;
}

void Session_OnStart(object Sender, EventArgs E)
{
       Application.Lock();
       Application["CurrentUsers"] = System.Convert.ToInt32(Application["CurrentUsers"]) + 1;
       Application.UnLock();
}
void Session_OnEnd(object Sender, EventArgs E)
{
       Application.Lock();
       Application["CurrentUsers"] = System.Convert.ToInt32(Application["CurrentUsers"]) - 1;
       Application.UnLock();
}

Hereafter you can handle the scenario as per your need.

Details here: http://www.aspdotnetfaq.com/Faq/How-to-show-number-of-online-users-visitors-for-ASP-NET-website.aspx[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900