Results 1 to 8 of 8

Thread: Session End

  1. #1

    Thread Starter
    Frenzied Member Fishcake's Avatar
    Join Date
    Feb 2001
    Location
    Derby, UK
    Posts
    1,092

    Session End

    When a session timeouts on my site i want the user to be redirected back to the homepage, telling them that the session has expired please log in again, blah blah.

    I've put a breakpoint on the session_end sub in global.aspx and this is firing once the session timeouts, how do i then make the broswer point to my SessionExpire.aspx page?

    Cheers.

  2. #2
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    You could use a Response.Redirect() to send the user to your page. Also, look into Forms Authentication and make sure you are not trying to re-invent the wheel here.

  3. #3

    Thread Starter
    Frenzied Member Fishcake's Avatar
    Join Date
    Feb 2001
    Location
    Derby, UK
    Posts
    1,092
    Response.redirect won't work from global.aspx, I'll try and have a look at Forms Authentication but i don't really have time now to make any major changes.

  4. #4

    Thread Starter
    Frenzied Member Fishcake's Avatar
    Join Date
    Feb 2001
    Location
    Derby, UK
    Posts
    1,092
    Forms Authentication looks useful, although i have already invented the wheel, still next time i'll use it.

    But is there a way i can redirect to a page from global.aspx? Am i using response.redirect wrong in that context?
    Code:
        Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)
            ' Fires when the session ends
            Response.Redirect("sessexpire.aspx")
        End Sub

  5. #5
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    Originally posted by Fishcake
    Response.redirect won't work from global.aspx, I'll try and have a look at Forms Authentication but i don't really have time now to make any major changes.
    It wont work in some instances where the session has not yet be initiated (Application_OnStart), but you have access to it in the session events. I would really re-think what you are doing and use Forms Authentication.

  6. #6
    Lively Member
    Join Date
    Oct 2001
    Location
    MA, US
    Posts
    78

    session_end will not work for webfarms

    If you are planning to do not keep the sessions on process, do not count on session_end, it will not work if you keep the sessions on sql or on state server

  7. #7
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    Not to mention Session_OnEnd is a little buggy, where it does not always fire off..

  8. #8

    Thread Starter
    Frenzied Member Fishcake's Avatar
    Join Date
    Feb 2001
    Location
    Derby, UK
    Posts
    1,092
    The Session_onEnd event seems to fire ok, I've set the session.timeout to 1 just for testing and it fires every minute.

    I've put a breakpoint on response.redirect("sessexpire.aspx") but after this line whilst debugging it switches back to the browser window but nothing happens.

    I would've used form authentication but am now very short on time, my project is about finished and this is the only thing i can't get working. How long would you estimate it would take me to implement authentication? is it a quick and painless process?

    Cheers.

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