Hello My Friends,
I have reached a way to resolve my problem. I am attaching the source code
of Global.asax that access an XML file whoisonline.xml and store the
online poeple as :
<?xml version="1.0" standalone="yes"?>
<whoisonline>
<profile>
<id>1</id>
<headline>Text Here</headline>
</profile>
</whoisonline>
Global.asax
Sub Session_End()
If Context.Request.IsAuthenticated Then
Application( "SessionCount" ) -= 1
Dim myDateSet = New DataSet()
myDateSet.ReadXml("M:\database\whoisonline.xml")
Dim myTable As DataTable = myDateSet.Tables("profile")
Dim id as string = Cstr(Context.User.Identity.Name)
Dim myDatarow as DataRow
For Each myDatarow in myTable.Rows
If myDatarow(0).ToString() = Id then
myDatarow(0).Delete()
Exit For
End If
Next
myDateSet.WriteXml("M:\database\whoisonline.xml")
End If
End Sub
Sub Application_AuthenticateRequest(ByVal sender As Object, ByVal e As
EventArgs)
If Context.Request.IsAuthenticated Then
If Application( "SessionCount" ) Is Nothing Then
Application( "SessionCount" ) = 0
End If
Application( "SessionCount" ) += 1
Dim myDateSet = New DataSet()
myDateSet.Readxml("M:\database\whoisonline.xml")
Dim myTable As DataTable = myDateSet.Tables("profile")
Dim strExpr as String
strExpr = "id = " & Context.User.Identity.Name
Dim foundRows() As DataRow
foundRows = myTable.Select(strExpr)
If foundRows.GetUpperBound(0) < 0 then
Dim myRow As DataRow
myRow = myTable.NewRow()
myRow("id") = Context.User.Identity.Name
Dim objFormsID As FormsIdentity
objFormsID = Context.User.Identity
myRow("headline") = objFormsID.Ticket.UserData
myTable.Rows.Add(myRow)
End If
myDateSet.WriteXml("M:\database\whoisonline.xml")
End If
End Sub
I have tried to store them as array in Application, but it was not much
reliable. So i thought of storing it in XML file. Do you think it is
better to store them as XML? or SQLServer Table? Is there any suggestions
for enhancing the above coding? thank you in advance...
Rabih