Detecting timeout with multiple websites on the same IIS server

Discussion in 'ASP .Net' started by Rob, Oct 10, 2007.

  1. Rob

    Rob Guest

    > This works - sort of. It works by checking to see if the ASP.NET_SessionId
    > cookie exists when a new session is started. If it is present, then this
    > is (supposed) to indicate that it's a new session.


    Sorry that should have read "(supposed) to indicate that it's a *timed out*
    session".

    Cheers, Rob.
    Rob, Oct 10, 2007
    #1
    1. Advertising

  2. Rob

    Rob Guest

    I'm using the well documented code to detect whether a timeout has occurred
    when a page is fetched in the OnInit() event handler:

    If Session.IsNewSession Then
    Dim CookieHeader As String = Request.Headers("Cookie")
    If Not CookieHeader Is Nothing AndAlso
    CookieHeader.IndexOf("ASP.NET_SessionId") >= 0 Then
    Request.Redirect("~/Timeout.aspx")
    End If
    End IF

    This works - sort of. It works by checking to see if the ASP.NET_SessionId
    cookie exists when a new session is started. If it is present, then this is
    (supposed) to indicate that it's a new session.

    However, if you have two applications running on the same IIS web server,
    then it triggers incorrectly. Both applications implement the above code.

    1. Open http://localhost/webapp1/default.aspx
    2. IsNewSession is true but cookie isn't present
    3. Open http://localhost/webapp2/default.aspx
    4. IsNewSession is true but the ASP.NET_SessionId cookie also exists (why is
    this?)

    Therefore the user is directed to the timeout page of webapp2.

    I've tried adding setting the path (in Session_Start event) of the
    Response.Cookie("ASP.NET_SessionId" to Request.PhysicalApplicationPath but
    that doesn't seem to make any difference.

    Any ideas?

    Thanks, Rob.
    Rob, Oct 10, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mark Starkman
    Replies:
    1
    Views:
    331
    Chris Jackson
    Mar 2, 2004
  2. Sammy
    Replies:
    5
    Views:
    456
    Sammy
    Jan 23, 2005
  3. Replies:
    0
    Views:
    433
  4. Maria
    Replies:
    0
    Views:
    96
    Maria
    Apr 13, 2005
  5. Mark Probert

    Timeout::timeout and Socket timeout

    Mark Probert, Oct 6, 2004, in forum: Ruby
    Replies:
    1
    Views:
    1,279
    Brian Candler
    Oct 6, 2004
Loading...

Share This Page