Handling requests that have a long response time

Discussion in 'ASP .Net' started by SJ, Dec 10, 2005.

  1. SJ

    SJ Guest

    I have a request to the server that could take upto 10 mins to come back
    and display the results.
    I want to either
    a) Redirect to a new "Please wait" page till the processing is done, then
    redirect back to the results page , or
    b) Display a "Please wait" message on the same page that sends the request
    to the server and refresh the page to display the results.
    I know websites like orbitz and travelocity do this.

    Any idea how I would accomplish this?

    Thanks,
    -SJ.
     
    SJ, Dec 10, 2005
    #1
    1. Advertising

  2. SJ

    Rob Meade Guest

    "SJ" wrote ...

    >I have a request to the server that could take upto 10 mins to come back
    > and display the results.
    > I want to either
    > a) Redirect to a new "Please wait" page till the processing is done, then
    > redirect back to the results page , or
    > b) Display a "Please wait" message on the same page that sends the request
    > to the server and refresh the page to display the results.
    > I know websites like orbitz and travelocity do this.
    >
    > Any idea how I would accomplish this?


    Hi SJ,

    I'm not sure if this is the "best" approach - but it is certain "an"
    approach :eek:)

    Presumably whatever you are 'triggering' is database driven? Hencing the
    processing time? My thought was that perhaps if you were able to ascertain
    an ID of sorts, you could keep redirecting to the same page every 10 seconds
    or something sending the ID in the form or querystring, and, if this page
    receives an ID then it checks the current "state" of the processing, until
    it comes back and says "I'm done" it keeps refreshing every 10 seconds.

    The page could easily have an animated .gif or something on it to indicate
    that something is still happening.

    As I said, probably not the best approach, but an approach none the less.

    I've fired things off using threading before to ensure they complete, but
    I've never (yet) had the need to wait around to see what the outcome was on
    the same request.

    I don't feel I've been much help - sorry..

    Rob
     
    Rob Meade, Dec 10, 2005
    #2
    1. Advertising

  3. SJ

    Matt Sollars Guest

    Rob,

    Don't sell your idea short. I think it's a valid one. I only see a
    couple of things I would recommend in addition.

    The "I'm done" state could certainly be represented by some Status
    field. I would refresh the current page at a larger interval than 10
    seconds if the operation could take 10 minutes. Set the refresh to occur
    5-10 seconds before the script timeout (i.e. Timeout = 90 seconds,
    refresh the page every 80 seconds).

    Perhaps, use a postback instead of a refresh with a querystring
    variable. I only say this to make things harder for tampering users or
    hackers. You could emit the JavaScript with a postback reference similar
    to the following:


    //-------------------------------------------------------

    private int TaskID {
    get {
    object Value = ViewState["TaskID"];
    if (Value == null)
    return 0;
    else
    return (int)Value;
    }
    set {
    ViewState["TaskID"] = value;
    }
    }

    private void Page_Load(object sender, System.EventArgs e) {
    if (Page.IsPostBack) {
    string JSFunction = GetPostBackEventReference(this);
    RegisterStartupScript("Refresh", "<script
    language=\"JavaScript\">window.setTimeout(\"" + JSFunction + "\", " +
    ((Server.ScriptTimeout - 10) * 1000).ToString() + "</script>");
    }
    }

    private void Button1_Click(object sender, System.EventArgs e) {
    // Retrieve some sort of task ID just before beginning the task.
    this.TaskID = GetNewTaskID();

    // Begin the very long procedure here.
    ...
    }

    //-------------------------------------------------------

    I really like the idea of an animated GIF image as well.


    Regards,

    Matt
     
    Matt Sollars, Dec 11, 2005
    #3
  4. SJ

    Spam Catcher Guest

    "SJ" <> wrote in news:lLFmf.35601$Zv5.128
    @newssvr25.news.prodigy.net:

    > I have a request to the server that could take upto 10 mins to come back
    > and display the results.


    What is processing the request?

    Database? Query? Service?

    If it's extreme long running, you may want to look at Message Queues...
    which will let you monitor the status of a pending request without tying up
    too many resources.

    --
    Stan Kee ()
     
    Spam Catcher, Dec 11, 2005
    #4
    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. George Marsaglia

    Assigning unsigned long to unsigned long long

    George Marsaglia, Jul 8, 2003, in forum: C Programming
    Replies:
    1
    Views:
    682
    Eric Sosman
    Jul 8, 2003
  2. Andy Leszczynski
    Replies:
    4
    Views:
    574
    Andy Leszczynski
    Mar 14, 2005
  3. Daniel Rudy

    unsigned long long int to long double

    Daniel Rudy, Sep 19, 2005, in forum: C Programming
    Replies:
    5
    Views:
    1,194
    Peter Shaggy Haywood
    Sep 20, 2005
  4. Mathieu Dutour

    long long and long

    Mathieu Dutour, Jul 17, 2007, in forum: C Programming
    Replies:
    4
    Views:
    478
    santosh
    Jul 24, 2007
  5. SJ

    Handling requests that take a long time.

    SJ, Dec 10, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    121
Loading...

Share This Page