[asp.net] weer een sessieprobleem

Pagina: 1
Acties:

  • barteke
  • Registratie: September 2002
  • Laatst online: 25-06-2023
hallo,

een pagina bestaat uit drie frames, left main en top.

telkens als de pagina opstart worden er twee sessie tegelijk gestart inplaats van 1 zoals het hoort.
ik denk dat het aan die frames ligt.

maare.. weet iemand hoe ik dit kan voorkomen? de usercount klopt zo van geen meter.

groeten,

Bart

I am a rock, I am an Island, and a rock feels no pain and an Island never cries


  • gorgi_19
  • Registratie: Mei 2002
  • Laatst online: 20-08 11:40

gorgi_19

Kruimeltjes zijn weer op :9

Handel de usercount af in je Global.Asax. Daar kan je hele mooie method (Session_OnStart) in kwijt...

[ Voor 43% gewijzigd door gorgi_19 op 28-03-2003 11:50 ]

Digitaal onderwijsmateriaal, leermateriaal voor hbo


  • barteke
  • Registratie: September 2002
  • Laatst online: 25-06-2023
dat doe ik ook..

Sub Session_Start()

Application( "SessionCount" ) += 1

End Sub

maar hij maakt twee unieke sessiestring aan bij elke herstart

I am a rock, I am an Island, and a rock feels no pain and an Island never cries


  • gorgi_19
  • Registratie: Mei 2002
  • Laatst online: 20-08 11:40

gorgi_19

Kruimeltjes zijn weer op :9

Laat je code eens helemaal zien?
Van je Global.Asax dan.

En vergeet geen [code=vb.net][/code] te gebruiken.. :+

[ Voor 40% gewijzigd door gorgi_19 op 28-03-2003 12:04 ]

Digitaal onderwijsmateriaal, leermateriaal voor hbo


  • barteke
  • Registratie: September 2002
  • Laatst online: 25-06-2023
Visual Basic .NET:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.Sqlclient" %>
<%@ Import Namespace="System.Security.Principal" %>
<%@ Import Namespace="System.Web.Mail" %>

<Script Runat="Server">

Dim conCommunity As SqlConnection
Dim strSelect As String
Dim cmdSelect As SqlCommand
Dim strInsert As String
Dim cmdInsert As SqlCommand
Dim strSessionID As String

Dim userID as Integer
        
Dim objUserIdentity As FormsIdentity

    Sub Application_Start()
        ' Fires when the application is started   
        
        Application( "MembersOnline" ) = New HashTable()
        
 End Sub
 
 

 
    Sub Session_Start()
    
        ' Fires when the session is started
        
        If Application( "SessionCount" ) Is Nothing Then
            Application( "SessionCount" ) = 0
        End If
        
             
If User.Identity.IsAuthenticated Then
        
        
        
        objUserIdentity = User.Identity
        
        userID = objUserIdentity.Ticket.UserData
        
            
If (Application( "MembersOnline" ).Contains( userID )) Then
                Application.Lock
            Application( "MembersOnline" ).Remove (userID)
            Application.Unlock
End IF                  

            
                Application.Lock
                    Application( "MembersOnline" ).Add ( userID,Session.SessionID )
                    Application.Unlock
                    End If
                
                
                End If
                
        Application( "SessionCount" ) += 1
        
End Sub
    
    
   

    Sub Application_BeginRequest()
    ' Fires at the beginning of each request
    End Sub

    Sub Application_AuthenticateRequest()
        ' Fires upon attempting to authenticate the use
        Dim objFormsID As FormsIdentity
        Dim intMemberID As Integer
        Dim intAuthorisationID As Integer
        Dim strRole As String
        Dim strRoles As String
        Dim arrRoles As String()
        Dim arrListRoles As New ArrayList()
        Dim conCommunity As SqlConnection
        Dim strSelect As String
        Dim cmdSelect As SqlCommand
        
        If Context.Request.IsAuthenticated Then     
            
            objFormsID = Context.User.Identity
            intMemberID = CInt( objFormsID.Ticket.Userdata )
            conCommunity = New SqlConnection( ConfigurationSettings.AppSettings("DSN") )
            conCommunity.Open()
                        
            strSelect = "Select AuthorisationID From Member Where ID = " & intMemberID
            cmdSelect = New SqlCommand(strSelect, conCommunity)
            
            intAuthorisationID = cmdSelect.ExecuteScalar()
            conCommunity.Close()
            
            Select intAuthorisationID
                Case 0
                    strRoles = "Normal;"
                Case 1
                    strRoles = "Normal;Moderator;"
                Case 2
                    strRoles = "Normal;Moderator;Moderator-Admin;"
                Case 3
                    strRoles = "Normal;Moderator;Moderator-Admin;Admin"
            End Select

            For Each strRole In strRoles.Split(New Char() {";"c})
                arrListRoles.Add(strRole)
            Next strRole

            arrRoles = CType(arrListRoles.ToArray(GetType(String)), String())
            Context.User = New GenericPrincipal( Context.User.Identity, arrRoles )
            
        End If     
            
    End Sub

    Sub Application_Error()
        Dim objMail As New MailMessage
        Dim ex As Exception = Context.Server.GetLastError().GetBaseException()

         objMail.From = ""
         objMail.To = ""
         objMail.Subject = "Error at Web site"
         objMail.Body = Request.Path
         objMail.Body &= vbNewLine
         objMail.Body &= ex.Message
         objMail.Body &= vbNewLine
         objMail.Body &= ex.Source
         SmtpMail.Send( objMail )
         Context.Server.ClearError()
    End Sub

    Sub Session_End()
        ' Fires when the session ends
        
        objUserIdentity = User.Identity
        
        userID = objUserIdentity.Ticket.UserData
        
        Application( "SessionCount" ) -= 1
        
        Application.Lock
        Application( "MembersOnline" ).Remove (userID)
        Application.Unlock
        
        
    End Sub

    Sub Application_End()
        ' Fires when the application ends
    End Sub
    
End Sub
</Script>

[ Voor 7% gewijzigd door barteke op 28-03-2003 12:16 ]

I am a rock, I am an Island, and a rock feels no pain and an Island never cries


  • gorgi_19
  • Registratie: Mei 2002
  • Laatst online: 20-08 11:40

gorgi_19

Kruimeltjes zijn weer op :9

* gorgi_19 ziet zo 123 niets geks... Wat je sowieso kan proberen is debuggen, en dat icm met Tracing, om zo te zien wat er gebeurd. :)

Digitaal onderwijsmateriaal, leermateriaal voor hbo


Verwijderd

je moet je application variable locken voordat je hem update...

Verwijderd

Misschien omslachtig maar het werkt:
Laat gewoon je global.asax ook het ip van de gebruiker opslaan in een Application() array samen met de session id, als er dan een IP 2maal voorkomt moet het gedelete worden en de usercount -1
Pagina: 1