473,414 Members | 1,697 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,414 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 1679
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.