473,466 Members | 1,408 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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

lu*******@hotmail.com
Nov 17 '05 #1
1 1464

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." <lu*******@hotmail.com> wrote in message
news:42**************************@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

lu*******@hotmail.com

Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Shelly | last post by:
This is driving me crazy and makes no sense. Any suggestions will be appreciated. I upload an image to a staging area. I have written software to look at the images, and if accepted it is...
13
by: dan roberts | last post by:
Folks, This is my first Python project so please bear with me. I need to download data from Yahoo Finance in CSV format. The symbols are provided in a text file, and the project details are...
3
by: MostlyH2O | last post by:
Hi Folks, I am trying to output the content of my ASP page to an MS Word Document with a specific page size (8.5x11) and margins (.25" all around). I have used the Response.ContentType =...
14
by: Simon Templar | last post by:
I have had problems several times with links to files to download. In one case I had a text file with different extension than txt, that, in case the user has the associated application installed,...
2
by: Yuriy | last post by:
I have a .NET server button on a form. When the user clicks it, I'd like to (behind the scenes) create a pdf file containing the data that they're currently viewing, then somehow activate the "Do...
13
by: ron1972 | last post by:
Hi I have a large pdf file that if I create an anchor link to, the browser will try to open the file, which takes quite a long time. Is there a way to force the browser to download the file rather...
36
by: Jules | last post by:
All, how do I describe a string consisting of any number of characters, with an optional (but unique when occuring) end-of-line expression '/'? With groups if possible, as in...
0
by: samjam | last post by:
Below is some coding in a program i am using, i would like to know how i can get the text bigger or bolder on my webpage, This is the section of text i would like bigger or bolder (This is a very...
3
by: cuties | last post by:
Hi all.... i'm very new to this programming language. i'm required to fulfill this task in the company i'm doing my practical. i hope i can get guide for my problem... Here is the script i...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.