473,401 Members | 2,127 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,401 software developers and data experts.

Downloading File Includes HTML ???

Why does the following code include the HTML page in the downloaded file

Response.ContentType="application/x-msdownload";
Response.AddHeader( "content-disposition","attachment; filename=download.txt");
FileStream sourceFile = new FileStream(@"c:\temp\scbdoif.txt", FileMode.Open);
long FileSize;
FileSize = sourceFile.Length;
byte[] getContent = new byte[(int)FileSize];
sourceFile.Read(getContent, 0, (int)sourceFile.Length);
sourceFile.Close();
Response.BinaryWrite(getContent);

When I download the file I will see ("<html>.....</html> at the end of the file.
Nov 18 '05 #1
1 978
because they are in the aspx page, whose content is rendered by default. you
can clear the content though:

Response.ClearContent();
Response.BinaryWrite(getContent);
Response.End();

-- bruce (sqlwork.com)


"johnz" <an*******@discussions.microsoft.com> wrote in message
news:73**********************************@microsof t.com...
Why does the following code include the HTML page in the downloaded file:

Response.ContentType="application/x-msdownload";
Response.AddHeader( "content-disposition","attachment; filename=download.txt"); FileStream sourceFile = new FileStream(@"c:\temp\scbdoif.txt", FileMode.Open); long FileSize;
FileSize = sourceFile.Length;
byte[] getContent = new byte[(int)FileSize];
sourceFile.Read(getContent, 0, (int)sourceFile.Length);
sourceFile.Close();
Response.BinaryWrite(getContent);
When I download the file I will see ("<html>.....</html> at the end of the

file.
Nov 18 '05 #2

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

Similar topics

2
by: AlexB | last post by:
I'm trying to download a text file to an IE client using the following code. The problem is that the saved file also includes the html for the page. Any ideas anyone? Private Sub...
4
by: Patrick | last post by:
I have an ASP site with about 50 ASP files, all of which are currently including a common "includes.asp" file near the top of the file, responsible for generating the <HEAD/> section of the HTML ...
2
by: AlexB | last post by:
I'm trying to download a text file to an IE client using the following code. The problem is that the saved file also includes the html for the page. Any ideas anyone? Private Sub...
3
by: Chuck Renner | last post by:
Please help! This MIGHT even be a bug in PHP! I'll provide version numbers and site specific information (browser, OS, and kernel versions) if others cannot reproduce this problem. I'm...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
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...

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.