473,320 Members | 2,080 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

download file to client machine

Hi All,

I am new to ASP.NET. I need to download a file from server to the client
machine.

Any ideas on how to go about this ?

Thanks In Advance.
Jul 21 '05 #1
6 1675
hi
make a link to your file and post it on your page.

cheers

"Nimesh" wrote:
Hi All,

I am new to ASP.NET. I need to download a file from server to the client
machine.

Any ideas on how to go about this ?

Thanks In Advance.

Jul 21 '05 #2
You can try something like this:

string FilePath = MapPath("design.doc");
Response.ContentType = "Application/msword";
Response.AppendHeader("content-disposition", "attachment;filename=" + "design.doc");
Response.WriteFile(FilePath);
Response.Flush();
Response.End();
Jul 21 '05 #3
If its a static choice, dont do this - as this is really annoying for people
who use download managers - you can't resume the download - and you can't
bookmark the download easily

--
Sriram Krishnan

http://www.dotnetjunkies.com/weblog/sriram
"Carolina" <cc******@gmx.net> wrote in message
news:f4**************************@posting.google.c om...
You can try something like this:

string FilePath = MapPath("design.doc");
Response.ContentType = "Application/msword";
Response.AppendHeader("content-disposition", "attachment;filename=" +
"design.doc");
Response.WriteFile(FilePath);
Response.Flush();
Response.End();

Jul 21 '05 #4
Carolina wrote:
You can try something like this:

string FilePath = MapPath("design.doc");
Response.ContentType = "Application/msword";
Response.AppendHeader("content-disposition", "attachment;filename=" + "design.doc");
Response.WriteFile(FilePath);
Response.Flush();
Response.End();


i do have the same problem. but how does this work for files located on
another machine??
this does not work:
string FilePath = MapPath("file.log");
Response.ContentType = "text/plain";
Response.AppendHeader("content-disposition", "attachment;filename=" +
"http://domain.com/file.log");
Response.WriteFile(FilePath);
Response.Flush();
Response.End();

is there a way to get this working too??

greets
wolfgang
Jul 21 '05 #5
wolfgang wagner wrote:
Carolina wrote:
You can try something like this:

string FilePath = MapPath("design.doc");
Response.ContentType = "Application/msword";
Response.AppendHeader("content-disposition", "attachment;filename="
+ "design.doc"); Response.WriteFile(FilePath);
Response.Flush();
Response.End();


i do have the same problem. but how does this work for files located
on another machine??
this does not work:
string FilePath = MapPath("file.log");
Response.ContentType = "text/plain";
Response.AppendHeader("content-disposition", "attachment;filename=" +
"http://domain.com/file.log");
Response.WriteFile(FilePath);
Response.Flush();
Response.End();

is there a way to get this working too??

greets
wolfgang


The AppendHeader line does two things:
- "attachment": makes the "save-box" pop up
- "filename": *suggests* a filename to use on the client-side
It does NOT specify the place to download the file from.

The WriteFile line places the server-file in the response-stream.
It might be possible to use UNC paths to point to a different
server in the local network (local as seen from the server!).
I don't think it is possible to point to a different webserver.
You might want to redirect instead! (also saves some network
traffic: why first get the file from the other server to your server
only to send it out again to the client?)

Hans Kesting
Jul 21 '05 #6
Hans Kesting wrote:


The AppendHeader line does two things:
- "attachment": makes the "save-box" pop up
- "filename": *suggests* a filename to use on the client-side
It does NOT specify the place to download the file from.

The WriteFile line places the server-file in the response-stream.
It might be possible to use UNC paths to point to a different
server in the local network (local as seen from the server!).
I don't think it is possible to point to a different webserver.
You might want to redirect instead! (also saves some network
traffic: why first get the file from the other server to your server
only to send it out again to the client?)

Hans Kesting


the problem is the location of the downloadable file. i've got a
download script which should "send" the corresponding file (one in
accessible only from internet, the other only from intranet) to the user
depending on his location (internet or intranet) and also insert some
data into a database.

wolfgang
Jul 21 '05 #7

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

Similar topics

7
by: atse | last post by:
Hi, I want the MP3 audio files to be able to download by users only. Even I set the pages validated by session, anyone still can type the download url to get my files without access of the pages...
0
by: Mike | last post by:
I have COM component and this need to be used in HTML file and hence need to be downloaded and registered at client machine. To achieve this I have created the INF file and compressed the COM and INF...
2
by: r dubey | last post by:
Hi, I'm using webclient to enable download of files. However, files get copied to the server rather than the client machine. What could be the problem. Here is the sample that I've used: ...
6
by: Nimesh | last post by:
Hi All, I am new to ASP.NET. I need to download a file from server to the client machine. Any ideas on how to go about this ? Thanks In Advance.
2
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview with answers Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of...
5
by: Samuel Shulman | last post by:
Hi everyone, I would like to implement the following functionality: User to enter username and password programmatically using the POST method Once the user is verified, start a download...
6
by: raymond_b_jimenez | last post by:
I need to download a file from an Intranet web site and feed it into a program on the PC where the browser is running. Browser is Internet Explorer. Both Javascript and VBscript are options. Which...
2
by: tiijnar | last post by:
Hi, In my application, I have an excel file stored on my server machine. How can I download that excel file on to my client machine using jsp. Is there any other way I can open that file from my...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.