|
-
March 3rd, 2009, 08:55 AM
#1
Infinte loop in session_start
Hello all,
I have a problem of infinite loop in my asp.net application in session_start.
it's located in global.asax and the code goes like this:
Code:
Try
Dim MyClassVars As MyClassVarsClass = New MyClassVarsClass
If Not HttpContext.Current.Request.Cookies("MaxmindVar") Is Nothing AndAlso HttpContext.Current.Request.Cookies("MaxmindVar").Value <> "" Then
sessionVisitor.InitializeSession(Request, Request.ServerVariables, Session, True, True, HttpContext.Current.Request.Cookies("MaxmindVar").Value)
Else
sessionVisitor.InitializeSession(Request, Request.ServerVariables, Session, True, True, PayoutsVars.MaxMindString)
End If
Catch ex As Exception
Log("MyClass", "SessionVisitor Problem. " & ex.ToString, False)
End Try
MyClassVars.SessionId = "pyhyt" & Session.SessionID
Dim requestedURL As String = Request.Url.ToString
If requestedURL.IndexOf("tid=") = -1 Then
' check if the url has something in the querystring, and handle accordingly
Dim token As String = MyHashing.cmpHashHandler.CreateToken(Session.SessionID)
MyClassVars.Token = token
MyClassVars.MaxMindString = "US"
MyHashing.cmpHashHandler.AddNewRecordToSortedList (token, MyClassVars)
If requestedURL.IndexOf("?") > -1 Then
requestedURL = requestedURL & "&tid=" & token
Else
requestedURL = requestedURL & "?tid=" & token
End If
End If
Response.Redirect(requestedURL)
Response.AppendToLog("SessionStart")
End If
when i run my app. it gets into this loop in this function.
I have the same code exactly in my laptop and no problem there so I guess the different machine may cause the problem, maybe I'm missing something? the iis configuratrion is also the same...
help?
-
March 4th, 2009, 12:02 AM
#2
Re: Infinte loop in session_start
You need to show more code...
-
March 4th, 2009, 02:43 AM
#3
Re: Infinte loop in session_start
this is the code...
remarking it solves the problem (but I need this code...)
-
March 5th, 2009, 02:12 AM
#4
Re: Infinte loop in session_start
Just a guess but is it possible that the initializesession is causing the session start to fire again?
-
March 5th, 2009, 02:39 AM
#5
Re: Infinte loop in session_start
nope.
I correct myself -
only this code shoyld be remarked to solve the problem:
Code:
MyClassVars.SessionId = "pyhyt" & Session.SessionID
Dim requestedURL As String = Request.Url.ToString
If requestedURL.IndexOf("tid=") = -1 Then
' check if the url has something in the querystring, and handle accordingly
Dim token As String = MyHashing.cmpHashHandler.CreateToken(Session.SessionID)
MyClassVars.Token = token
MyClassVars.MaxMindString = "US"
MyHashing.cmpHashHandler.AddNewRecordToSortedList (token, MyClassVars)
If requestedURL.IndexOf("?") > -1 Then
requestedURL = requestedURL & "&tid=" & token
Else
requestedURL = requestedURL & "?tid=" & token
End If
End If
Response.Redirect(requestedURL)
Response.AppendToLog("SessionStart")
End If
my guess it's something with the response.redirect...
any ideas anyone??
-
March 5th, 2009, 01:05 PM
#6
Re: Infinte loop in session_start
 Originally Posted by amirt
nope.
I correct myself -
only this code shoyld be remarked to solve the problem:
my guess it's something with the response.redirect...
any ideas anyone??
Have you tried the code like this ...
Code:
MyClassVars.SessionId = "pyhyt" & Session.SessionID
Dim requestedURL As String = Request.Url.ToString
If requestedURL.IndexOf("tid=") = -1 Then
' check if the url has something in the querystring, and handle accordingly
Dim token As String = MyHashing.cmpHashHandler.CreateToken(Session.SessionID)
MyClassVars.Token = token
MyClassVars.MaxMindString = "US"
MyHashing.cmpHashHandler.AddNewRecordToSortedList (token, MyClassVars)
If requestedURL.IndexOf("?") > -1 Then
requestedURL = requestedURL & "&tid=" & token
Else
requestedURL = requestedURL & "?tid=" & token
End If
Response.Redirect(requestedURL)
End If
Response.AppendToLog("SessionStart")
End If
you should only need to redirect if you alter the url ....
Gremmy..
Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
WPF Articles : 3D Animation 1 , 2 , 3
Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|