Session ending without any warning!

Discussion in 'ASP .Net' started by Arti, Jul 12, 2007.

  1. Arti

    Arti Guest

    Hi everybody,

    I am using ASP.NET 2.0.

    When redirecting from page1 to page2 using Response.Redirect() method
    ThreadAbortException is raised.

    In my condition sometimes even though this exception is caught and handled
    by my code, the session_end method in global.asax is getting called, which
    implies that all my sessions are ended and hence i am forced to login once
    again!

    Can somebody please let me know what i am missing here, any solution to
    avoid this error...

    Thanks and Regards.
    Arti, Jul 12, 2007
    #1
    1. Advertising

  2. "Arti" <> wrote in message
    news:...

    > When redirecting from page1 to page2 using Response.Redirect() method
    > ThreadAbortException is raised.
    >
    > In my condition sometimes even though this exception is caught and handled
    > by my code, the session_end method in global.asax is getting called, which
    > implies that all my sessions are ended and hence i am forced to login once
    > again!
    >
    > Can somebody please let me know what i am missing here, any solution to
    > avoid this error...


    The Response.Redirect method has an overload whereby you tell it not to
    abort the thread:
    http://msdn2.microsoft.com/en-us/library/a8wa7sdt(VS.80).aspx

    I'm not convinced that this will solve the problem, though, because it
    certainly shouldn't be tearing down your session...

    Worth a try in the first instance, though...


    --
    Mark Rae
    ASP.NET MVP
    http://www.markrae.net
    Mark Rae [MVP], Jul 12, 2007
    #2
    1. Advertising

  3. "Arti" <> wrote in message
    news:...
    > Hi everybody,
    >
    > I am using ASP.NET 2.0.
    >
    > When redirecting from page1 to page2 using Response.Redirect() method
    > ThreadAbortException is raised.
    >
    > In my condition sometimes even though this exception is caught and handled
    > by my code, the session_end method in global.asax is getting called, which
    > implies that all my sessions are ended and hence i am forced to login once
    > again!
    >
    > Can somebody please let me know what i am missing here, any solution to
    > avoid this error...


    I'm not sure this is the same I have seen, but if you redirect to another
    page while the first page still has an open database connection, this may be
    the result. So make sure everything is cleaned up before redirecting to
    another page. Then you will not get that exception at all.

    Bjorn
    Bjorn Sagbakken, Jul 12, 2007
    #3
  4. Arti

    Arti Guest

    Thanks Mark, I tried that one out but it doesn't work... :(

    Hi Bjorn,
    The problem is that this problem occurs only in certain conditions... Do you
    still think this solution will solve the problem?

    Regards
    Arti.

    "Bjorn Sagbakken" <> wrote in message
    news:p...
    > "Arti" <> wrote in message
    > news:...
    >> Hi everybody,
    >>
    >> I am using ASP.NET 2.0.
    >>
    >> When redirecting from page1 to page2 using Response.Redirect() method
    >> ThreadAbortException is raised.
    >>
    >> In my condition sometimes even though this exception is caught and
    >> handled by my code, the session_end method in global.asax is getting
    >> called, which implies that all my sessions are ended and hence i am
    >> forced to login once again!
    >>
    >> Can somebody please let me know what i am missing here, any solution to
    >> avoid this error...

    >
    > I'm not sure this is the same I have seen, but if you redirect to another
    > page while the first page still has an open database connection, this may
    > be the result. So make sure everything is cleaned up before redirecting to
    > another page. Then you will not get that exception at all.
    >
    > Bjorn
    >
    Arti, Jul 16, 2007
    #4
  5. "Arti" <> wrote in message
    news:...
    > Thanks Mark, I tried that one out but it doesn't work... :(
    >
    > Hi Bjorn,
    > The problem is that this problem occurs only in certain conditions... Do
    > you still think this solution will solve the problem?


    I don't know, depends on the details in your conditions. Let's say you
    retrieve database records, and sometimes you encounter unexpected values
    like dbNull where there is supposed to be a number. If this situation isn't
    taken into the code, you may get an exeption that escapes the open thread.
    There are all sort of possibilities in this direction, but since I don't
    know anything about the app or the conditions when this happens, I am only
    guessing.

    Bjorn
    Bjorn Sagbakken, Jul 17, 2007
    #5
    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. Thomas Bindzau

    Re: ASPNET Session ending before time

    Thomas Bindzau, Jun 24, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    1,377
    Thomas Bindzau
    Jun 24, 2003
  2. Big Daddy
    Replies:
    2
    Views:
    392
    Laurent Bugnion
    May 8, 2006
  3. Nick Chan

    Ending Execution without Response.end

    Nick Chan, Oct 9, 2007, in forum: ASP .Net
    Replies:
    1
    Views:
    543
    bruce barker
    Oct 9, 2007
  4. Julian Mehnle
    Replies:
    17
    Views:
    852
    Julian Mehnle
    May 18, 2006
  5. Tobius
    Replies:
    3
    Views:
    104
    Thomas 'PointedEars' Lahn
    Mar 29, 2006
Loading...

Share This Page