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

Discussion in 'ASP .Net Web Services' started by Ollie, Jul 15, 2004.

  1. Ollie

    Ollie Guest

    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
    Ollie, Jul 15, 2004
    #1
    1. Advertising

  2. Ollie

    Hans Kesting Guest

    "Ollie" <> wrote in message news:...
    > 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
    Hans Kesting, Jul 15, 2004
    #2
    1. Advertising

  3. Ollie

    Ollie Guest

    cheers but you total missed the point

    "Hans Kesting" <> wrote in message
    news:%...
    >
    > "Ollie" <> wrote in message

    news:...
    > > 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
    >
    >
    Ollie, Jul 15, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ollie
    Replies:
    2
    Views:
    602
    Ollie
    Jul 15, 2004
  2. Dave Brown

    Not Strictly Java but...

    Dave Brown, Mar 23, 2005, in forum: Java
    Replies:
    0
    Views:
    331
    Dave Brown
    Mar 23, 2005
  3. Barn
    Replies:
    0
    Views:
    134
  4. Stephanie Stowe
    Replies:
    2
    Views:
    201
    Peter X
    Apr 7, 2004
  5. Frances Del Rio

    not strictly a JS question, but....

    Frances Del Rio, Sep 26, 2004, in forum: Javascript
    Replies:
    7
    Views:
    225
    Richard Cornford
    Oct 11, 2004
Loading...

Share This Page