Friday, April 08, 2011

Firefox Update panel after 2 mins idle time

Recently, I fight with firefox bug which aborting my partial postback from update panel after 2 mins idle time.

Here was my step to investigate this problem

  • check other browsers (IE, IE6, Chrome) – and the result, only firefox does this weird behaviour
  • create simple update panel and tested on FF. – unfortunately this work perfectly
    and then I wonder why my actual code does not work.
  • Apply more content on Update Panel – It is not work again (oh my be it’s I need to make my content on update panel smaller)
  • After trying to make my update panel content smaller, it still not work.
  • Then I use my previous simple update panel to test if it is content outside update panel is matter. – (Yes, it is the content outside update panel is matter)
  • Confuse how I solve this, we still need to use update panel for particular reason because of the due date, etc. so we can’t change anything (we have to keep the update panel but has to work in FF)

After looking around the solutions, luckily I found on the other section of my project work perfectly after 2 mins idle in FF.

I try to investigate why that section work but not this. Finally I figure out that the different is that part is calling ajax call on other page before call partial postback.

Then here is my simple solutions to fix this.

  • Register Begin Request
    Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(microsoftAJAX_BeginRequest);
  • check the browser if it is mozilla and the time difference is 2 mins then request to other server page (ASPX page) first synchonously before continue the process.

    Here is the code, hopefully it will help your problem as well.
    //check availability for partial postback for FF fixed. FF will abort the partial postback call after 2 mins unless it call ajax to other page first
    var checkConnectionForPartialPostback = function ()
    {
    $.ajax({
    url: "/usercontrols/testconnection.aspx",
    async: false
    });
    };

    //check availability for partial postback for FF fixed. FF will abort the partial postback call after 2 mins unless it call ajax to other page first
    var checkAvailabilityForPartialPostback = function ()
    {
    //firefox fix for time diff
    if ($.browser.mozilla && GetTimeDiff(new Date(), lastLoadTime).getMinutes() >= 2)
    {
    //refresh this page
    checkConnectionForPartialPostback();
    }
    else
    {
    lastLoadTime = new Date();
    }
    };







1 comment:

Corey said...

Great tip. I am working on a chat web app that uses jsonp to make a long-polling request to a node.js server. Was going crazy trying to figure out why firefox was ignoring the 10 minute timeout I was giving it, and just failing after 2 minutes.

Now on boot-up my app sends a ping request to the node server, and then future requests are actually allowed their full 10 minutes.