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? :blush:
Re: Infinte loop in session_start
You need to show more code...
Re: Infinte loop in session_start
this is the code...
remarking it solves the problem (but I need this code...)
Re: Infinte loop in session_start
Just a guess but is it possible that the initializesession is causing the session start to fire again?
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??
Re: Infinte loop in session_start
Quote:
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..