473,406 Members | 2,698 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,406 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 18 '05 #1
2 999

"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 18 '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 18 '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: ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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.