SaveAs excel Dialog and IIS ConnectionTimeOut

Discussion in 'ASP .Net' started by N. Shehzad, Apr 20, 2010.

  1. N. Shehzad

    N. Shehzad Guest

    Experts:
    I have a following code that allows a user to download excel file. However
    if the download dialog has been sitting there for more than two minutes which
    is connectiontimeout setting on IIS, user cannot download the file, and it
    results in error. How can I keep the connection open, so that if users goes
    for restroom break, and meanwhile the popup saveAs dialog has shown up
    without changing the connectionTimeOut property on the IIS server?

    //request was not aborted
    Response.Clear();
    Response.ClearContent();
    Response.ClearHeaders();
    Response.ContentType = "application/vnd.ms-excel";
    Response.AddHeader("Content-Disposition", "attachment;
    filename=" + _fileDisplayName);
    Response.Charset = "";
    if (System.IO.File.Exists(Server.MapPath(".") + "\\" +
    _xlFileName))
    Response.TransmitFile(Server.MapPath(".") + "\\" +
    _xlFileName);
    Response.Flush();
    N. Shehzad, Apr 20, 2010
    #1
    1. Advertising

  2. "N. Shehzad" <> wrote in message
    news:...

    > How can I keep the connection open, so that if users goes
    > for restroom break, and meanwhile the popup saveAs dialog has shown up
    > without changing the connectionTimeOut property on the IIS server?


    In your post, you are asking "solve my problem the way I want to solve it"
    rather than focusing on the problem. I see two potential problems:

    1. User clicks button and then ignorantly walks away in the few seconds it
    takes to produce the file (ie, does not understand how web apps work)
    2. User clicks button and the creation process takes so damned long he has
    to pee.

    In other words, which of these are we actually solving:

    "How can I use technology to protect users who don't understand how the web
    works?"
    or
    "The time to create the Excel file is so long, the person's bladder gets
    full before it is finished".

    NOTE: Without focusing on the true problem (disease?), you are only abating
    symptoms. If a doctor prescribed pain pills for cancer, you would fire him,
    as he is not fighting the disease. So, be a good doctor and fight the
    disease, not the symptoms. I have two paths you can go down, depending on
    what the disease, not the symptom, is.


    Assuming the technology needs to protect ignorant users
    Unfortunately, anything you do will only prolong the agony, but here are
    some things you can try if you truly want to protect users from clicking "I
    want this file" and then immediately saying "I need to pee".

    1. Increase timeout in IIS - has ramifications on scale and performance, but
    it is an option
    2. Create a download manager and queue up downloads so the download does not
    start any part of the process until the guy figures he is done urinating
    3. Use a technology that allows more time, as you can control the process
    better than HTML/HTTP - Silverlight comes to mind

    If you coded a modal dialog, you could time it out. With IE, the popup is on
    the user side. But you might find a clever way to shut the dialog down and
    redirect the user to a "don't walk away from the machine when you request a
    download".

    Assuming the process takes too long:
    The other implication here is the save dialog is taking too long to display,
    which is a completely different issue. If it takes too long to create the
    Excel file, I would consider doing this asynch and alerting the user when he
    can download. Then there is no time to go and pee after he clicks the link.

    Important takeaway:
    You have to figure out which is the real problem (time to create file or
    user is not getting it) and aim at that problem. If the file is taking too
    long, then trying to protect the user is a foolish direction to head in, as
    it DOES NOT solve the real problem. It only masks the symptoms.

    --
    Peace and Grace,
    Greg

    Twitter: @gbworld
    Blog: http://gregorybeamer.spaces.live.com

    ************************************************
    | Think outside the box! |
    ************************************************
    Gregory A. Beamer, Apr 21, 2010
    #2
    1. Advertising

  3. N. Shehzad wrote:
    > if (System.IO.File.Exists(Server.MapPath(".") + "\\" +
    > _xlFileName))


    Just incidentally, you may find it a bit neater to use Server.MapPath("~/" +
    _xlFileName) to get the file.

    Regarding the timeout issue, does it take a long time for the "Save As..."
    dialog to appear, or do the users get the dialog up and then walk off?

    If the former, you could try a Response.Flush() after setting the headers so
    that /something/ is sent to the browser to give it a chance to show the
    dialog quickly. Also, using an HttpHandler (in an .ashx file) could improve
    the response time as it involves less overhead.
    http://msdn.microsoft.com/en-us/library/system.web.ihttphandler.processrequest.aspx

    --
    Andrew
    Andrew Morton, Apr 22, 2010
    #3
    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. Jeffrey A. Voigt

    Possible to do a File SaveAs Dialog In ASP.NET

    Jeffrey A. Voigt, Jun 16, 2004, in forum: ASP .Net
    Replies:
    6
    Views:
    5,688
    Jeffrey A. Voigt
    Jun 17, 2004
  2. N. Shehzad

    SaveAs excel Dialog and IIS ConnectionTimeOut

    N. Shehzad, Apr 20, 2010, in forum: ASP .Net Security
    Replies:
    0
    Views:
    789
    N. Shehzad
    Apr 20, 2010
  3. Dan Sikorsky

    HOWTO: Force the SaveAs Dialog Box For Downloads

    Dan Sikorsky, Apr 20, 2004, in forum: ASP General
    Replies:
    3
    Views:
    236
    Dan Sikorsky
    Apr 21, 2004
  4. Tim Meagher
    Replies:
    1
    Views:
    321
    Bob Barrows [MVP]
    Oct 4, 2005
  5. Martin Mrazek
    Replies:
    0
    Views:
    168
    Martin Mrazek
    May 18, 2004
Loading...

Share This Page