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

not strictly an asp.net or C# question but?.....

The client I am currently working is using a thrid party framework to
generate web content, this framework utilizes asp.net web services I have
written for them, one of these web services streams the contents of file for
download by the end user.

My question is how do I write the following bit of code as pure HTML so that
the web service can return the complete HTML script required to download the
file so that the third party then can display the HTML a they require, hope
this makes sense...

The code lets the user download a txt file when the asp.net page is loaded
or a button is click, but what is the HTML output for this?

FileStream fileStream = new FileStream("C:\\XXXXX\\Test.txt", FileMode.Open,
FileAccess.Read);
long fileSize;
fileSize = fileStream.Length;
byte[] buffer = new byte[(int)fileSize];
fileStream.Read(buffer, 0, (int)fileSize);
fileStream.Close();
Response.ContentType = "application/txt";
Response.AddHeader( "content-disposition", "attachment;
filename=RJL00102.x01");
Response.BinaryWrite(buffer);

Cheers in advance

Ollie
Nov 16 '05 #1
2 2161

"Ollie" <ol**********@hotmail.com> wrote in message news:uu**************@TK2MSFTNGP10.phx.gbl...
The client I am currently working is using a thrid party framework to
generate web content, this framework utilizes asp.net web services I have
written for them, one of these web services streams the contents of file for
download by the end user.

My question is how do I write the following bit of code as pure HTML so that
the web service can return the complete HTML script required to download the
file so that the third party then can display the HTML a they require, hope
this makes sense...

The code lets the user download a txt file when the asp.net page is loaded
or a button is click, but what is the HTML output for this?

FileStream fileStream = new FileStream("C:\\XXXXX\\Test.txt", FileMode.Open,
FileAccess.Read);
long fileSize;
fileSize = fileStream.Length;
byte[] buffer = new byte[(int)fileSize];
fileStream.Read(buffer, 0, (int)fileSize);
fileStream.Close();
Response.ContentType = "application/txt";
Response.AddHeader( "content-disposition", "attachment;
filename=RJL00102.x01");
Response.BinaryWrite(buffer);

Cheers in advance

Ollie


One note: I'm not sure fileStream.Read(buffer, 0, (int)fileSize);
is guaranteed to read exactly fileSize bytes.

Your should just output the contents of the file (along with an http-header),
it shouldn't add extra html (you did remove everything except directives
from the aspx file?).

If the file really exists on disk, you could also look at the
HttpResponse.WriteFile method.
Hans Kesting
Nov 16 '05 #2
cheers but you total missed the point

"Hans Kesting" <ne***********@spamgourmet.com> wrote in message
news:%2***************@TK2MSFTNGP09.phx.gbl...

"Ollie" <ol**********@hotmail.com> wrote in message news:uu**************@TK2MSFTNGP10.phx.gbl...
The client I am currently working is using a thrid party framework to
generate web content, this framework utilizes asp.net web services I have written for them, one of these web services streams the contents of file for download by the end user.

My question is how do I write the following bit of code as pure HTML so that the web service can return the complete HTML script required to download the file so that the third party then can display the HTML a they require, hope this makes sense...

The code lets the user download a txt file when the asp.net page is loaded or a button is click, but what is the HTML output for this?

FileStream fileStream = new FileStream("C:\\XXXXX\\Test.txt", FileMode.Open, FileAccess.Read);
long fileSize;
fileSize = fileStream.Length;
byte[] buffer = new byte[(int)fileSize];
fileStream.Read(buffer, 0, (int)fileSize);
fileStream.Close();
Response.ContentType = "application/txt";
Response.AddHeader( "content-disposition", "attachment;
filename=RJL00102.x01");
Response.BinaryWrite(buffer);

Cheers in advance

Ollie


One note: I'm not sure fileStream.Read(buffer, 0, (int)fileSize);
is guaranteed to read exactly fileSize bytes.

Your should just output the contents of the file (along with an

http-header), it shouldn't add extra html (you did remove everything except directives
from the aspx file?).

If the file really exists on disk, you could also look at the
HttpResponse.WriteFile method.
Hans Kesting

Nov 16 '05 #3

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

Similar topics

1
by: Xah Lee | last post by:
with strict HTML spec, can one have <p> tags inside table's <td> tag? also, in strict XHTML, can one have <p> tages inside <div>? Thanks. Xah xah@xahlee.org ∑ http://xahlee.org/
7
by: Frances Del Rio | last post by:
hello all, I have a question that is not striclty a JS question but figured folks here would know.. what IS the difference between Netscape and mozilla?? I have used both, they have the same...
3
by: MLH | last post by:
Is the Between ... And operator strictly reserved for use in SQL?
2
by: Ollie | last post by:
The client I am currently working is using a thrid party framework to generate web content, this framework utilizes asp.net web services I have written for them, one of these web services streams...
17
by: Mike | last post by:
I'm trying to create a page: Three sections (left, topright and bottomright), each with a heading and scrolling (overflow) content. The size of these sections should be based upon the size of the...
3
by: Tony Girgenti | last post by:
Hello. When i develop a web form program using VS.NET 2003(VB), ASP.NET 1.1, i can put a statement like this in my VB code-behind source file: ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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...
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:
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...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.