CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Jun 2004
    Posts
    61

    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?

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Infinte loop in session_start

    You need to show more code...
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Jun 2004
    Posts
    61

    Re: Infinte loop in session_start

    this is the code...
    remarking it solves the problem (but I need this code...)

  4. #4
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: Infinte loop in session_start

    Just a guess but is it possible that the initializesession is causing the session start to fire again?

  5. #5
    Join Date
    Jun 2004
    Posts
    61

    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??

  6. #6
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    Re: Infinte loop in session_start

    Quote Originally Posted by amirt View Post
    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
  •  





Click Here to Expand Forum to Full Width

Featured