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

O

Ollie

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
 
H

Hans Kesting

Ollie said:
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
 
O

Ollie

cheers but you total missed the point

Hans Kesting said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,992
Messages
2,570,220
Members
46,807
Latest member
ryef

Latest Threads

Top