473,800 Members | 3,052 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Download text file


Hi

I want to offer people to actually download text file and not view it on
browser (which is what happens by default)

Thank you,
Samuel
Jun 14 '07 #1
3 1238
You can force the download control by using :
http://support.microsoft.com/kb/260519/en-us
(applies as well to ASP.NET)

Once thr header is written you can then use Response.WriteF ile to stream the
file to the browser...

--
Patrice

"Samuel" <sa************ @ntlworld.coma écrit dans le message de news:
uk************* *@TK2MSFTNGP04. phx.gbl...
>
Hi

I want to offer people to actually download text file and not view it on
browser (which is what happens by default)

Thank you,
Samuel

Jun 14 '07 #2
I added the following code:

Response.AddHea der("content-disposition", "attachment ;
filename=FileNa me.txt")

Response.ClearC ontent()

Response.WriteF ile("FileName.t xt")

But I get mcuh more content than the text file

Thank you,
Samuel

"Patrice" <http://www.chez.com/scribe/wrote in message
news:u5******** *****@TK2MSFTNG P02.phx.gbl...
You can force the download control by using :
http://support.microsoft.com/kb/260519/en-us
(applies as well to ASP.NET)

Once thr header is written you can then use Response.WriteF ile to stream
the file to the browser...

--
Patrice

"Samuel" <sa************ @ntlworld.coma écrit dans le message de news:
uk************* *@TK2MSFTNGP04. phx.gbl...
>>
Hi

I want to offer people to actually download text file and not view it on
browser (which is what happens by default)

Thank you,
Samuel


Jun 15 '07 #3
That is ? Make sure also to clear the markup etc.. Basically such a page
should return anything but your content (i.. you shouldn't return any HTML,
html code, master pages content etc...). Though it's likely better to clean
up these elements for clarity a quick way to check this would to use
Response.end to end the streaming once the file is trnasmitted.

If the content is no more there this is because your page renders other
things at a later time (such as HTML markup if you have still this in your
ASPX page).

--
Patrice

"Samuel" <sa************ @ntlworld.coma écrit dans le message de news:
O3************* @TK2MSFTNGP06.p hx.gbl...
>I added the following code:

Response.AddHea der("content-disposition", "attachment ;
filename=FileNa me.txt")

Response.ClearC ontent()

Response.WriteF ile("FileName.t xt")

But I get mcuh more content than the text file

Thank you,
Samuel

"Patrice" <http://www.chez.com/scribe/wrote in message
news:u5******** *****@TK2MSFTNG P02.phx.gbl...
>You can force the download control by using :
http://support.microsoft.com/kb/260519/en-us
(applies as well to ASP.NET)

Once thr header is written you can then use Response.WriteF ile to stream
the file to the browser...

--
Patrice

"Samuel" <sa************ @ntlworld.coma écrit dans le message de news:
uk************ **@TK2MSFTNGP04 .phx.gbl...
>>>
Hi

I want to offer people to actually download text file and not view it on
browser (which is what happens by default)

Thank you,
Samuel



Jun 15 '07 #4

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

Similar topics

5
5836
by: peetm | last post by:
I'd like to write to a log whenever a visitor to my site downloads a file. So, I'd like the link they click to be to a php 'page' that returns the file. Don't know how to do that! Side Question ... Presumably, the dialog that you see when you download a binary (asking for a 'Save As...' file name) is put up by your browser when it 'sees' non-text data coming back as a response? So, how would you download a text file - and cause...
5
6130
by: Brandon Walters | last post by:
I wrote a file download module for my website. The reason for the file download module is that my website downloads work on a credit based system. So I need to keep track of and limit daily downloads. It uses fpassthru() and some headers() to send a file to the requesting user. The get.php file that I wrote (the file download module if you will) works like a charm for .ZIP files and .TXT files. However, when .EXE files are downloaded...
2
2015
by: Tom Youngquist | last post by:
I am trying to download a text file that my .NET page has just created based on entered parameters on the web page. Everything seems to work and the file is created. I am using the following code to start the download process: Response.Clear() Response.ContentType = "text/plain" Response.AppendHeader("Content-Disposition", "attachment; filename=" & fileName) Response.AppendHeader("Content-Description", "This is your Cost Journal...
0
2584
by: jmd | last post by:
Hello. I want to write a C# program that does completely automatically what, until now, I do manually, witch is describe below : 1. I launch IE (6) 2. I browse to my desired download page, say http://www.site.com/download This download page contains some textboxes, checkboxes, radiobuttons, a DOWNLOAD BUTTON and text 3. I check some checkboxes, select some radiobuttons, enter text in some textboxes and click on the download button
0
1750
by: Rhys666 | last post by:
Basically I have a link that opens my download page and the querystring identifies the type of 'template' Excel spreadsheet has asked to download. The download page reads the querystring, identifies the template required then uses Response.AppendHeader to amend the response to create the file download dialogue. On my local machine this works fine and the download dialogue correctly identifies the file name and type attempting to be...
4
2336
by: Nathan Sokalski | last post by:
I want to give visitors to my site the option of downloading a generated ..txt file by clicking a button. I know how to generate text files, but how do I cause the browser to pop up one of those dialog boxes that says something like "Do you want to download FILEX.txt?" I want the user to be able to download the file rather than have the file displayed in the browser, because the file will include some characters such as tabs and commas....
18
16408
by: jmd | last post by:
Hello, I posted the following in the C# forum but without one answer. But perhaps now in vb.net someone has some guidelines ! This is my question : I want to write a vb.net program that does completely automatically what, until now, I do manually, witch is describe below : 1. I launch IE (6)
3
2143
by: tshad | last post by:
I have a function that downloads a file to the users computer and it works fine. The problem is that I then want the program to rename the file (file.move) to the same name plus todays date. The problem is that when you run the program it gets to the: Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name)
16
3262
by: matt | last post by:
I have used some free code for listing files for download, but I want to send an email to the administrator when the file has been downloaded. I have got some code in here that does it, but it will not print in the username or email amddress of the person doing the download - which I am collecting from a form on the previous page. I can get the name and email address to print out normally, just not into the email sending body. I have...
1
47492
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click on a link and after a moment or two a file download dialog box pops-up in your web browser and prompts you for some instructions, such as “open” or “save“. I’m going to show you how to do that using a perl script. What You Need Any recent...
0
9694
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10509
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10256
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10039
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6824
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5477
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4152
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3765
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2953
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.