ASP.NET Page /Admin/SessionUsers.aspx.cs (C#)
1: using System;  
2: using System.Data;  
3: using System.Configuration;  
4: using System.Collections;  
5: using System.Web;  
6: using System.Web.Security;  
7: using System.Web.UI;  
8: using System.Web.UI.WebControls;  
9: using System.Web.UI.WebControls.WebParts;  
10: using System.Web.UI.HtmlControls;  
11: using System.Data.SqlClient;  
12: using QuizNetOnline.Logic;  
13: using QuiznetOnline.Data;  
14: using System.Reflection;  
15: using System.Web.SessionState;  
16: using System.Collections.Generic;  
17:   
18: public partial class SessionUsers : System.Web.UI.Page  
19: {  
20:     protected void Page_Load(object sender, EventArgs e)  
21:     {  
22:         if (Session["Validated"] == null || (bool)Session["Validated"] == false)  
23:             Response.Redirect("Default.aspx");  
24:   
25:             Dictionary<string, HttpSessionState> sessionData = (Dictionary<string, HttpSessionState>)Application["sessionData"];  
26:   
27:             HttpSessionState ss = HttpContext.Current.Session;  
28:             Response.Write("My current SessionID - " + ss.SessionID + "<br><br>");  
29:   
30:             if (sessionData != null)  
31:             {  
32:                 foreach (KeyValuePair<string, HttpSessionState> item in sessionData)  
33:                 {  
34:                     if (item.Value != null && item.Value.Count > 0)  
35:                     {  
36:                         foreach (string key in item.Value.Keys)  
37:                         {  
38:                             if (key == "userWeb" && ss.SessionID != item.Key)  
39:                             {  
40:                                 UserWeb userWeb = (UserWeb)item.Value[key];  
41:                                 Response.Write("UserName - " + userWeb.UserName + "<br>");  
42:                                 Response.Write("SessionID - " + item.Key + "<br>");  
43:                                 Response.Write("UserLocation - " + userWeb.UserLocation.CountryName + "," + userWeb.UserLocation.RegionName + "," + userWeb.UserLocation.City + "<br>");  
44:                                 Response.Write("Duration(min) - " + DateTime.Now.Subtract(userWeb.SessionStartDateTime).Minutes + "<br>");  
45:                                 Response.Write("NumberOfQuestionsAnswered - " + userWeb.NumberOfQuestionsAnswered + "<br>");  
46:                                 Response.Write("<br>-----------------------------------<br>");  
47:                             }  
48:                         }  
49:                     }  
50:   
51:                 }  
52:             }  
53:   
54:     }  
55: }  

.NET Documentation Tool is © 2002 - 2009 Winnersh Triangle Web Solutions Limited.