Save generated response stream as a html file

Discussion in 'ASP .Net' started by Tom Vergote, Jun 3, 2004.

  1. Tom Vergote

    Tom Vergote Guest

    Hello world,

    I'm running into an issue where I would like to save the response stream as
    an html file on the server (and convert it to a pdf)

    I've tried putting a streamreader on the outputstream like in the following
    code, but the stream doesn't seem to be readable

    Is there any way to do this?

    --- CODE----
    string path = Server.MapPath("testfile.html");
    StringWriter sw = new StringWriter();


    StreamWriter sWriter = File.CreateText(path);
    sWriter.WriteLine(sw.ToString());
    StreamReader sr = new StreamReader(Response.OutputStream);
    sWriter.Write(sr.ReadToEnd());
    sWriter.Close();
    string pdf = Run(path); // THIS SHOULD CONVERT TO PDF
    Response.ClearContent();
    Response.ClearHeaders();
    Response.ContentType = "Application/pdf";
    try
    {
    Response.WriteFile( MapPath( pdf ) );
    Response.Flush();
    Response.Close();
    }
    catch (Exception ex)
    {
    Response.ClearContent();
    }
    -----/CODE-------
    Tom Vergote, Jun 3, 2004
    #1
    1. Advertising

  2. "Tom Vergote" <> wrote in message
    news:...
    > Hello world,
    >
    > I'm running into an issue where I would like to save the response stream

    as
    > an html file on the server (and convert it to a pdf)


    Look into HttpResponse.Filter. It may serve your needs.
    --
    John Saunders
    johnwsaundersiii at hotmail
    John Saunders, Jun 3, 2004
    #2
    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. Eirik Eldorsen
    Replies:
    4
    Views:
    13,612
    Eirik Eldorsen
    Aug 26, 2005
  2. Brock Allen

    Re: Save HTML to Stream

    Brock Allen, Sep 20, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    456
    Brock Allen
    Sep 20, 2005
  3. =?Utf-8?B?U3RldmUgQy4gT3Jy?=

    RE: Save HTML to Stream

    =?Utf-8?B?U3RldmUgQy4gT3Jy?=, Sep 21, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    456
    =?Utf-8?B?U3RldmUgQy4gT3Jy?=
    Sep 21, 2005
  4. Replies:
    0
    Views:
    395
  5. Replies:
    9
    Views:
    612
    Alex Buell
    Apr 27, 2006
Loading...

Share This Page