Window closes unexpectedly when downloading a file

Discussion in 'ASP .Net' started by bfmcfarlane@gmail.com, Feb 22, 2007.

  1. Guest

    I have an appication that allows users to upload and download files.
    This application is only accessed when a user clicks on an "Upload /
    Download" link from within our main application. A new window is
    launched asking the user which file he /she wants to download. After
    the user determines which file to download, the window disappears but
    the user is provided with the download file dialog box. I have been
    able to track it down to a specific line of code that I believe is
    causing this behavior.

    Response.Clear();
    Response.ContentType = "cis/file-text";
    Response.AddHeader("Content-Disposition", "attachment; filename=" +
    tempFileName);
    Response.BinaryWrite(result);

    The third line where I provide teh header details causes the page to
    close. If I comment out this line, the page does not close and
    obviously the file is not downloaded.

    If I access this application directly by opening up IE and typing in
    the url, this behavior does not occurr and everything works as
    designed. I am struggling with why does this only happen when the
    appliaction is accessed via javascript.

    Any help is appreciated
    , Feb 22, 2007
    #1
    1. Advertising

  2. Patrice Guest

    It never shows a window (the browser sees that the content is not directed
    to its window). When used from a browser it acutally just left the current
    window unchanged. If you go directly to the url without displaying a browser
    window (ie. launched from an external possibly Windows application ?) it
    looks like expected it doesn't display anything.


    <> a écrit dans le message de news:
    ...
    >I have an appication that allows users to upload and download files.
    > This application is only accessed when a user clicks on an "Upload /
    > Download" link from within our main application. A new window is
    > launched asking the user which file he /she wants to download. After
    > the user determines which file to download, the window disappears but
    > the user is provided with the download file dialog box. I have been
    > able to track it down to a specific line of code that I believe is
    > causing this behavior.
    >
    > Response.Clear();
    > Response.ContentType = "cis/file-text";
    > Response.AddHeader("Content-Disposition", "attachment; filename=" +
    > tempFileName);
    > Response.BinaryWrite(result);
    >
    > The third line where I provide teh header details causes the page to
    > close. If I comment out this line, the page does not close and
    > obviously the file is not downloaded.
    >
    > If I access this application directly by opening up IE and typing in
    > the url, this behavior does not occurr and everything works as
    > designed. I am struggling with why does this only happen when the
    > appliaction is accessed via javascript.
    >
    > Any help is appreciated
    >
    Patrice, Feb 22, 2007
    #2
    1. Advertising

  3. Guest

    On Feb 22, 11:09 am, "Patrice" <http://www.chez.com/scribe/> wrote:
    > It never shows a window (the browser sees that the content is not directed
    > to its window). When used from a browser it acutally just left the current
    > window unchanged. If you go directly to the url without displaying a browser
    > window (ie. launched from an external possibly Windows application ?) it
    > looks like expected it doesn't display anything.
    >
    > <> a écrit dans le message de news:
    > ...
    >
    >
    >
    > >I have an appication that allows users to upload and download files.
    > > This application is only accessed when a user clicks on an "Upload /
    > > Download" link from within our main application. A new window is
    > > launched asking the user which file he /she wants to download. After
    > > the user determines which file to download, the window disappears but
    > > the user is provided with the download file dialog box. I have been
    > > able to track it down to a specific line of code that I believe is
    > > causing this behavior.

    >
    > > Response.Clear();
    > > Response.ContentType = "cis/file-text";
    > > Response.AddHeader("Content-Disposition", "attachment; filename=" +
    > > tempFileName);
    > > Response.BinaryWrite(result);

    >
    > > The third line where I provide teh header details causes the page to
    > > close. If I comment out this line, the page does not close and
    > > obviously the file is not downloaded.

    >
    > > If I access this application directly by opening up IE and typing in
    > > the url, this behavior does not occurr and everything works as
    > > designed. I am struggling with why does this only happen when the
    > > appliaction is accessed via javascript.

    >
    > > Any help is appreciated- Hide quoted text -

    >
    > - Show quoted text -


    I guess I need to provide more detail. My application contains a
    frameset, display and hidden. When the user is navigated to the
    application, a list of files to be downloaded appears. The user
    clicks on a hyperlink, which calls javascript. The javascript loads a
    web page into each frame. The dispaly frame is loaded with a page
    asking the user if the file was downloaded succesfully or if an error
    occurs. The hidden frame is loaded with a page that retrieves the
    file and sends to the user. The user should then go from a list of
    files to be downloaded to a confirmation page.

    Are you saying that since the hidden frame does not have any content
    to output that it will close the entire web browser?
    , Feb 22, 2007
    #3
  4. Patrice Guest

    Nope as you see I didn't understood the whole context.

    My first move would be to make the hidden frame visible in case initiating a
    download from an hidden frame would be something unexpected side effect...
    You could also for now get rid of the confirmation page to just keep the
    download page the goal for now being to find out what is the change that
    would make this work before seeing what could be done about it.

    I would aslo likely try a bare bone simialr archtiercture with an IFRAME
    just to see...

    Good luck.

    <> a écrit dans le message de news:
    ...
    On Feb 22, 11:09 am, "Patrice" <http://www.chez.com/scribe/> wrote:
    > It never shows a window (the browser sees that the content is not directed
    > to its window). When used from a browser it acutally just left the current
    > window unchanged. If you go directly to the url without displaying a
    > browser
    > window (ie. launched from an external possibly Windows application ?) it
    > looks like expected it doesn't display anything.
    >
    > <> a écrit dans le message de news:
    > ...
    >
    >
    >
    > >I have an appication that allows users to upload and download files.
    > > This application is only accessed when a user clicks on an "Upload /
    > > Download" link from within our main application. A new window is
    > > launched asking the user which file he /she wants to download. After
    > > the user determines which file to download, the window disappears but
    > > the user is provided with the download file dialog box. I have been
    > > able to track it down to a specific line of code that I believe is
    > > causing this behavior.

    >
    > > Response.Clear();
    > > Response.ContentType = "cis/file-text";
    > > Response.AddHeader("Content-Disposition", "attachment; filename=" +
    > > tempFileName);
    > > Response.BinaryWrite(result);

    >
    > > The third line where I provide teh header details causes the page to
    > > close. If I comment out this line, the page does not close and
    > > obviously the file is not downloaded.

    >
    > > If I access this application directly by opening up IE and typing in
    > > the url, this behavior does not occurr and everything works as
    > > designed. I am struggling with why does this only happen when the
    > > appliaction is accessed via javascript.

    >
    > > Any help is appreciated- Hide quoted text -

    >
    > - Show quoted text -


    I guess I need to provide more detail. My application contains a
    frameset, display and hidden. When the user is navigated to the
    application, a list of files to be downloaded appears. The user
    clicks on a hyperlink, which calls javascript. The javascript loads a
    web page into each frame. The dispaly frame is loaded with a page
    asking the user if the file was downloaded succesfully or if an error
    occurs. The hidden frame is loaded with a page that retrieves the
    file and sends to the user. The user should then go from a list of
    files to be downloaded to a confirmation page.

    Are you saying that since the hidden frame does not have any content
    to output that it will close the entire web browser?
    Patrice, Feb 22, 2007
    #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. feng
    Replies:
    1
    Views:
    459
    Cowboy \(Gregory A. Beamer\)
    Dec 3, 2003
  2. ChrisC
    Replies:
    11
    Views:
    2,880
    ChrisC
    Feb 7, 2007
  3. Johnson

    Visual Studio Closes Unexpectedly

    Johnson, Nov 4, 2008, in forum: ASP .Net
    Replies:
    3
    Views:
    1,822
    David Wang
    Nov 6, 2008
  4. Charles R. Thompson
    Replies:
    6
    Views:
    141
    Ben Liddicott
    Jan 13, 2004
  5. Spammay Blockay
    Replies:
    1
    Views:
    401
    Dietmar Meier
    Feb 4, 2005
Loading...

Share This Page