473,386 Members | 1,647 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,386 software developers and data experts.

download writes html code to file

Hi all,
I was wondering why when i create a text file and download it through my
website, the download will include all the html code for the given page at
the bottom of the text file.

i'm using asp.net
--
Ad****@hotmail.com
Nov 19 '05 #1
3 1126
Response.WriteFile (assuming this is what you are using) does nothing else
than inserting the file content in the current output. The page is still
processed as usual and in particular its HTML code is rendered.
Generally a streaming page doesn't have any HTML code as it's sole purpose
is to output the raw content of a file.

Some code may help in case you are not doing things this way.

Patrice

--

"ACaunter" <Ad****@hotmail.com> a écrit dans le message de
news:D1**********************************@microsof t.com...
Hi all,
I was wondering why when i create a text file and download it through my
website, the download will include all the html code for the given page at
the bottom of the text file.

i'm using asp.net
--
Ad****@hotmail.com

Nov 19 '05 #2
because you are creating it incorrectly...or streaming it incorrectly.
We'll need some code snippet

--
Curt Christianson
Site & Scripts: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"ACaunter" <Ad****@hotmail.com> wrote in message
news:D1**********************************@microsof t.com...
Hi all,
I was wondering why when i create a text file and download it through my
website, the download will include all the html code for the given page at
the bottom of the text file.

i'm using asp.net
--
Ad****@hotmail.com

Nov 19 '05 #3
Here is my download code:

Dim iStream As System.IO.Stream = Nothing
Dim buffer(10000) As Byte
Dim length As Integer
Dim dataToRead As Long
Dim filepath As String = x
Dim filename As String = System.IO.Path.GetFileName(filepath)
'Try
iStream = New System.IO.FileStream(filepath,
System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read)
dataToRead = iStream.Length
Response.ContentType = "application/octet-stream"
Response.AddHeader("Content-Disposition", "attachment;
filename=" + filename)
While dataToRead > 0
If Response.IsClientConnected Then
length = iStream.Read(buffer, 0, 10000)
Response.OutputStream.Write(buffer, 0, length)
Response.Flush()
buffer(1000) = New Byte
dataToRead = dataToRead - length
Else
dataToRead = -1
End If
End While
'Catch ex As Exception
' Response.Write("Error : " + ex.Message)
'Finally
If Not (iStream Is Nothing) Then
iStream.Close()
End If
Nov 19 '05 #4

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

Similar topics

4
by: Alexander Gilman Carver | last post by:
I have written a pair of scripts that are supposed to work together to display an index of files and then, upon the user choosing the files (with checkboxes on an HTML form submitted to itself),...
2
by: Michael Foord | last post by:
I'm creating a CGI that offers files for download. After googling I though I had the right headers to send to force a download - but it sends the data to the browser instead of opening the download...
3
by: Lachlan Gemmell | last post by:
Hello there, I'd like to set the users default download folder on their PC to a certain location (if it exists). The users will be downloading documents and we want to try to minimise the...
0
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,...
1
by: Brett Kelly | last post by:
Ok, I know this sounds odd. Let me explain further. I have an ASP.net page (w/ C# code behind) that, when given a session variable containing the path to a local file, will attempt to start the...
2
by: Jan Paul van de Berg | last post by:
I have a piece of software that people can download and a third party promoting that software. In order for them to be able to count the number of downloads, I have to put a tracking code on my...
1
by: a.r.austin | last post by:
Hello, I am trying to download a few files one after another from a remote server. Problem is that I don't know how to, or if I am able at all, set a time out for download. I don't want to time...
16
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...
1
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...

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.