downloading a file

Discussion in 'ASP .Net' started by Sean, Jun 18, 2004.

  1. Sean

    Sean Guest

    Hi all,

    I am creating a web application to convert files to a different
    format. The interface is simple in that there's a filename control
    and a submit buttom. The functionality I'm looking for is for the
    user to use the filename control to indicate which file to convert,
    then to press submit, the file is then uploaded to the application,
    converted, and then the response for the user would be a 'Save file
    as..' dialog, and they then can indicate where to save the converted
    file. I have got everything working up to the point where I have to
    respond with the new file. I can't figure out how to set it up so
    that their browser expects to download a file. I would ideally like
    to stick the converted file in the Response object but there doesn't
    seem to be a function for this. I also wish to avoid placing the file
    somewhere else and then replying with a link for them to follow to get
    at this file. Is there a clean way to do this?

    thanks,
    Sean
    Sean, Jun 18, 2004
    #1
    1. Advertising

  2. Hi,
    Use something like this

    context.Response.ContentType = "Application/pdf"
    context.Response.ContentType = "Application/msword"
    context.Response.ContentType = "Application/x-msexcel"
    context.Response.ContentType = "application/octet-stream"

    and

    If you want this to be downloaded then
    context.Response.AddHeader("content-disposition", "attachment;
    filename=" & strFileName)

    If you want the browser to open it using the default viewer then use
    this.
    context.Response.AddHeader("content-disposition", "filename=" &
    strFileName)


    Trevor Benedict R
    MCSD

    *** Sent via Devdex http://www.devdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Trevor Benedict R, Jun 19, 2004
    #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. Ian Gordon

    Downloading a file...

    Ian Gordon, Jul 30, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    942
    Ian Gordon
    Jul 30, 2003
  2. Chris Morrison

    Downloading a file from a website

    Chris Morrison, Dec 18, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    507
    Vijayakrishna Pondala
    Dec 31, 2003
  3. Replies:
    0
    Views:
    407
  4. Steven

    Downloading a file

    Steven, Jul 28, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    388
    Joerg Jooss
    Aug 2, 2003
  5. Ian Gordon

    Downloading a file to client

    Ian Gordon, Jul 30, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    355
    Bill Priess
    Jul 30, 2003
Loading...

Share This Page