Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. global.asax session help

global.asax session help

Scheduled Pinned Locked Moved .NET (Core and Framework)
sysadminhelp
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    boyindie
    wrote on last edited by
    #1

    Hi i have a logging session which i use in the global.asax file which determines if the user is authenticated to the system i ahve it working within reason but if i try to access a page before logging in it will render page then will write my relogin page to the same page I want it to redirect to this page relogin page if the user isn't authenticated on the system, so that nothing is showing by the browser i have the following code

    Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
    ' Code that runs when a new session is started
    Session("loggedin") = "False"
    CheckLoggedIn()
    Session.Timeout = 20

    End Sub
    
    Sub Application\_OnPostRequestHandlerExecute()
        CheckLoggedIn()
    End Sub
    
    'Check that the user is logged in.
    Sub CheckLoggedIn()
        'If the user is not logged in and you are not currently on the Login Page.
        If InStr(Request.RawUrl, "default.aspx") Or InStr(Request.RawUrl, "passwordrecover") And Session("loggedin") = "null" Then
         
            
        ElseIf Session("Loggedin") = "False" Then
            server.transfer("relogin.aspx")
            
        ElseIf Session("Loggedin") = "True" Then
            
            
        End If
          
    End Sub
    
    Sub Session\_End(ByVal sender As Object, ByVal e As EventArgs)
        ' Code that runs when a session ends. 
        ' Note: The Session\_End event is raised only when the sessionstate mode
        ' is set to InProc in the Web.config file. If session mode is set to StateServer 
        ' or SQLServer, the event is not raised.
        Server.Transfer("relogin.aspx")
    
    End Sub
    

    I have also tryed using response.redirect, but this jus does the same in thing IE, and firefox will jus timeout everytime any help appreciated boyindie

    S 1 Reply Last reply
    0
    • B boyindie

      Hi i have a logging session which i use in the global.asax file which determines if the user is authenticated to the system i ahve it working within reason but if i try to access a page before logging in it will render page then will write my relogin page to the same page I want it to redirect to this page relogin page if the user isn't authenticated on the system, so that nothing is showing by the browser i have the following code

      Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
      ' Code that runs when a new session is started
      Session("loggedin") = "False"
      CheckLoggedIn()
      Session.Timeout = 20

      End Sub
      
      Sub Application\_OnPostRequestHandlerExecute()
          CheckLoggedIn()
      End Sub
      
      'Check that the user is logged in.
      Sub CheckLoggedIn()
          'If the user is not logged in and you are not currently on the Login Page.
          If InStr(Request.RawUrl, "default.aspx") Or InStr(Request.RawUrl, "passwordrecover") And Session("loggedin") = "null" Then
           
              
          ElseIf Session("Loggedin") = "False" Then
              server.transfer("relogin.aspx")
              
          ElseIf Session("Loggedin") = "True" Then
              
              
          End If
            
      End Sub
      
      Sub Session\_End(ByVal sender As Object, ByVal e As EventArgs)
          ' Code that runs when a session ends. 
          ' Note: The Session\_End event is raised only when the sessionstate mode
          ' is set to InProc in the Web.config file. If session mode is set to StateServer 
          ' or SQLServer, the event is not raised.
          Server.Transfer("relogin.aspx")
      
      End Sub
      

      I have also tryed using response.redirect, but this jus does the same in thing IE, and firefox will jus timeout everytime any help appreciated boyindie

      S Offline
      S Offline
      saniy
      wrote on last edited by
      #2

      Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs) ' Code that runs when a new session is started just remove Session("loggedin") = "False" then try else just set Session("loggedin") = Null CheckLoggedIn() Session.Timeout = 20 End Sub saniya khengar v

      B 1 Reply Last reply
      0
      • S saniy

        Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs) ' Code that runs when a new session is started just remove Session("loggedin") = "False" then try else just set Session("loggedin") = Null CheckLoggedIn() Session.Timeout = 20 End Sub saniya khengar v

        B Offline
        B Offline
        boyindie
        wrote on last edited by
        #3

        I have got it working now but it doesn't allow null as its outdated, it will only allow a dbNull but i just set it session="" works jus as well

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups