IE File Download Dialog

Discussion in 'ASP .Net' started by RN1, Aug 8, 2008.

  1. RN1

    RN1 Guest

    In an ASP.NET app, users can upload their files to a remote server as
    back-up. I want to give users the provision to download files that
    they have uploaded to the remote server to their local machine. This
    is how I am invoking the file download dialog box that pops up in IE6
    (users click a Button):

    Sub btn_DwnldFile(ByVal obj As Object, ByVal ea As EventArgs)
    Dim strURL As String = 'getting the file name

    Response.ContentType = "application/octet-stream"
    Response.AddHeader("Content-Disposition", "attachment;filename=" &
    strURL)

    'hdnCurrentDir is a hidden Form element
    Response.TransmitFile(hdnCurrentDir.Value & "\" & strURL)
    Response.TransmitFile(Path.Combine(hdnCurrentDir.Value, strURL))
    Response.Flush()
    Response.End()
    End Sub

    As such the above code invokes the IE file download dialog
    successfully but the problem is in the file download dialog box, if
    the user clicks the 'Open' button (instead of clicking the 'Save'
    button to save the file in his local machine), then the file opens up
    in the same window. I did like the file to open up in a new window.

    I am not sure how to go about implementing this. Can someone please
    give me some idea on how to do this?

    Thanks,

    Ron
     
    RN1, Aug 8, 2008
    #1
    1. Advertising

  2. On Aug 8, 11:46 am, RN1 <> wrote:
    > In an ASP.NET app, users can upload their files to a remote server as
    > back-up. I want to give users the provision to download files that
    > they have uploaded to the remote server to their local machine. This
    > is how I am invoking the file download dialog box that pops up in IE6
    > (users click a Button):
    >
    > Sub btn_DwnldFile(ByVal obj As Object, ByVal ea As EventArgs)
    >     Dim strURL As String = 'getting the file name
    >
    >     Response.ContentType = "application/octet-stream"
    >     Response.AddHeader("Content-Disposition", "attachment;filename=" &
    > strURL)
    >
    >     'hdnCurrentDir is a hidden Form element
    >     Response.TransmitFile(hdnCurrentDir.Value & "\" & strURL)
    >     Response.TransmitFile(Path.Combine(hdnCurrentDir.Value, strURL))
    >     Response.Flush()
    >     Response.End()
    > End Sub
    >
    > As such the above code invokes the IE file download dialog
    > successfully but the problem is in the file download dialog box, if
    > the user clicks the 'Open' button (instead of clicking the 'Save'
    > button to save the file in his local machine), then the file opens up
    > in the same window. I did like the file to open up in a new window.
    >
    > I am not sure how to go about implementing this. Can someone please
    > give me some idea on how to do this?
    >
    > Thanks,
    >
    > Ron


    You can replace the button by a link to the separated webform (e.g.
    download.aspx) with target=_blank
     
    Alexey Smirnov, Aug 8, 2008
    #2
    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. Daniel Cardoso
    Replies:
    1
    Views:
    799
    Daniel Cardoso
    Sep 24, 2004
  2. Ryan Taylor
    Replies:
    2
    Views:
    1,025
    Ryan Taylor
    Nov 10, 2004
  3. Sam --
    Replies:
    2
    Views:
    668
    Sam --
    Mar 17, 2005
  4. Kele
    Replies:
    0
    Views:
    2,839
  5. =?Utf-8?B?SWJyYWhpbS4=?=

    File name is displayed Garbled in "File download dialog box"

    =?Utf-8?B?SWJyYWhpbS4=?=, Aug 12, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    493
    =?Utf-8?B?SWJyYWhpbS4=?=
    Aug 12, 2006
Loading...

Share This Page