Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > not strictly an asp.net or C# question but?.....

Reply
Thread Tools

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

 
 
Ollie
Guest
Posts: n/a
 
      07-15-2004
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


 
Reply With Quote
 
 
 
 
Hans Kesting
Guest
Posts: n/a
 
      07-15-2004

"Ollie" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> 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


 
Reply With Quote
 
 
 
 
Ollie
Guest
Posts: n/a
 
      07-15-2004
cheers but you total missed the point

"Hans Kesting" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
>
> "Ollie" <(E-Mail Removed)> wrote in message

news:(E-Mail Removed)...
> > 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
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Not strictly a Voip question, about call blocking David Woolley UK VOIP 0 05-25-2012 09:30 PM
Not Strictly Java but... Dave Brown Java 0 03-23-2005 11:40 AM
not strictly a JS question, but.... Frances Del Rio Javascript 7 10-11-2004 12:03 AM
not strictly an asp.net or C# question but?..... Ollie ASP .Net Web Services 2 07-15-2004 01:49 PM
maintaining control with cookies (not strictly an ASP or even server side question. But not not either) Stephanie Stowe ASP General 2 04-07-2004 04:23 PM



Advertisments