HELP: How to I download a file without viewing it in ASP.NET?

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default HELP: How to I download a file without viewing it in ASP.NET?

    I need to download a file like MS Word doc
    from a web form without viewing it. Something
    that goes directly to the 'Save As' dialog.

    Right now the browser takes over the displays
    the document.

    Is this possible?

    TIA

    [email]luvdotnet@hotmail.com[/email]
    Elrey Ronald V. Guest

  2. Similar Questions and Discussions

    1. Help! Cannot delete PDF file after viewing.
      I have a program written in asp which would view a scanned pdf document and delete it after coping to other folder. It use to work fine until I...
    2. Viewing PDF file after printing.
      Until this last week, Distiller would automatically open the new PDF file for viewing. Now, I have to go to the file location and open manually. I...
    3. PDF Viewing and Download issues
      Since I switched to a mac PowerPook G4 using OSX last week, every time I view a .pdf in Mozilla it puts a copy on my desktop. I'd like to decide...
    4. Adding a PDF to a Web Page for Download or Viewing
      OK, I know its simple, but could anyone please direct me to a tutorial or tell me how to add a pdf file to a web page. I have a Job Application that...
    5. Viewing a RTF File on Web Site
      We have the following problem: There is a RTF file that must be viewed on browser and we have been developed a solution in Java to do it. But the...
  3. #2

    Default Re: How to I download a file without viewing it in ASP.NET?


    This is what I do:

    // see if s/b downloaded rather than viewed

    if( download )

    {

    Response.AddHeader("Content-Disposition",

    "attachment; filename=\"" + theDocument.OriginalFileName + "\"" );

    }

    // make the reposnse

    Response.Clear();

    Response.ContentType = theDocument.FileType;

    Response.Flush();

    Response.WriteFile(theDocument.StoredFilePath);

    Response.End();


    'download' is a boolean extracted from the query string. Setting the
    Content_Disposition and attachment is sufficient to cause the download
    save as dialog to open (in IE6 anyway), otherwise it will attempt to
    view it in IE6, if no viewer is found in will then download anyway.

    HTH
    Charles


    "Elrey Ronald V." <luvdotnet@hotmail.com> wrote in message
    news:4268ec58.0307020604.79229141@posting.google.c om...
    > I need to download a file like MS Word doc
    > from a web form without viewing it. Something
    > that goes directly to the 'Save As' dialog.
    >
    > Right now the browser takes over the displays
    > the document.
    >
    > Is this possible?
    >
    > TIA
    >
    > [email]luvdotnet@hotmail.com[/email]

    Charles Rumbold Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139