I wanna share…

Showing Current number of user in online is common in the part of developing a web site.

How to achieve that??? very simple.

1. Add Global.asax file to your application(web)

2. Add this code…

void Application_Start(object sender, EventArgs e)
{
Application[“Users”] = 0;
}

void Session_Start(object sender, EventArgs e)
{
Application.Lock();
Application[“Users”] = (int)Application[“Users”] + 1;
Application.UnLock();
}

void Session_End(object sender, EventArgs e)
{
Application.Lock();
Application[“Users”] = (int)Application[“Users”] – 1;
Application.UnLock();
}

3. In the web.config file write this code…

<system.web>
<sessionState mode=”InProc” cookieless=”false” timeout=”15″ />
</system.web>

 

4. Use this code in your Home Page

No. of users in online ::::: <%= Application[“Users”].ToString() %>

 

5. Build and Run the application.

Hope it help you….

 

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: