Page view counter

ASP.NET AJAX UpdatePanel and Session Timeout

Last post 01-08-2009 6:07 PM by rdionne11. 5 replies.

Sort Posts:

  • ASP.NET AJAX UpdatePanel and Session Timeout

    12-12-2007, 2:36 PM
    • Loading...
    • jhalavirendra
    • Joined on 05-06-2003, 4:29 AM
    • Posts 29
    • Points 39

    Hi All,

    I am using ASP.NET AJAX 1.0.

    I am using UpdatePanel to generate different controls in filter panel depending upon selected item in a dropdown.

    I am facing issues with session timeout as nothing happens if session is timed out. No error message is shown by AJAX as normally we can see a jacascript alert in case of any exception during async ajax call.

    I have error handling code in place in Global.asx as well as in Scripmanager's "OnAsyncPostbackError" event but none of these events are fired.

    Is there anyway to detect session timeout when using update panel?

    Regards,
    Virendra Jhala

     

  • Re: ASP.NET AJAX UpdatePanel and Session Timeout

    12-12-2007, 3:33 PM
    Answer
    • Loading...
    • oswaldorb
    • Joined on 04-02-2007, 3:32 PM
    • Houston
    • Posts 28
    • Points 51

    You can use this code on every page of the app, or just create a base calls for all your pages that need to check for session timeout :

    protected override void OnPreInit(EventArgs e)

    {

    base.OnPreInit(e);

    if (Context.Session != null)

    {

    if (Session.IsNewSession)

    {

    string cookieHeader = Request.Headers["Cookie"];

    if (!String.IsNullOrEmpty(cookieHeader) && cookieHeader.IndexOf("ASP.NET_SessionId") >= 0)

    {

    Response.Redirect("~/SessionExpiredPage.aspx", true);

    }

    }

    }

    }

    ______________________________________________
    Oswaldo Rodriguez
    ozinabox.com
  • Re: ASP.NET AJAX UpdatePanel and Session Timeout

    12-12-2007, 10:29 PM

    You can handle in Global.asx file in Session_End event.

    Redirect to login page in this event

    Chetan Sarode
    Software Engineer,
    Approva Systems Pvt Ltd,
    Pune, India.
  • Re: ASP.NET AJAX UpdatePanel and Session Timeout

    12-13-2007, 10:35 AM
    • Loading...
    • jhalavirendra
    • Joined on 05-06-2003, 4:29 AM
    • Posts 29
    • Points 39

    Hi Chetan,

    It seems that you did not read my post as I already mentioned that I am handling things in Global.asx level but the event does not fire at all due to async postback.

    Regards
    Virendra Jhala

  • Re: ASP.NET AJAX UpdatePanel and Session Timeout

    12-13-2007, 11:20 AM
    • Loading...
    • oswaldorb
    • Joined on 04-02-2007, 3:32 PM
    • Houston
    • Posts 28
    • Points 51

    Did you try the solution I gave you? Works for me and my UpdatePanels Stick out tongue

    ______________________________________________
    Oswaldo Rodriguez
    ozinabox.com
  • Re: ASP.NET AJAX UpdatePanel and Session Timeout

    01-08-2009, 6:07 PM
    • Loading...
    • rdionne11
    • Joined on 04-20-2007, 3:12 PM
    • Posts 16
    • Points 46

    That idea didn't work for me either. I'm using an AJAX tab control and after my session times out, it gives me an error 12030 (server closed connection or something like that) when I change tabs. It still switches to the new tab but I don't think it can execute any server-side code at that point. If I change to go to a different page in my site, I get redirected to the session timeout notification page as I should. Trying to use the scriptmanager asyncpostbackerror event didn't work either.

Page 1 of 1 (6 items)