Page.Render do not render complete page

Discussion in 'ASP .Net' started by Lau Lei Cheong, May 15, 2004.

  1. Hello,

    I'm writing a web page using ASP.NET that with send the page's HTML
    content to user through e-mail. My plan is to dump the content to a file
    then email it to user as attachment.

    The following the part of the code I used:
    [Begin of Quote]
    StreamWriter MyWriter = myfile.CreateText();
    MemoryStream renderedPage = new MemoryStream(10240);
    Html32TextWriter myWriter = new Html32TextWriter(new
    StreamWriter(renderedPage, System.Text.Encoding.UTF8));

    this.Render(myWriter);
    //Breakpoint I'm pointing at
    renderedPage.Position = 0;
    using (StreamReader sr = new StreamReader(renderedPage))
    {
    MyWriter.Write(sr.ReadToEnd());
    sr.Close();
    MyWriter.Close();
    }
    [End of Quote]

    And the following is the fragment where the saved page on server stop at:

    [Begin of Quote]
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    <HTML>
    <HEAD>
    .......
    <tr>
    <td bgcolor="#FFFFFF" align="center">2</td>
    <td bgcolor="#FFFFFF">ABCDEFG</td>
    <td bgcolor="#FFFFFF" align="center">2</td>
    <td bgcolor="#FFFFFF">100</td>
    <td bgcolor="#FFFFFF">200</td>
    </tr>
    <tr>
    <td bgcolor="#FFFFFF" align="center">3</td>
    <td bgcolor="#FFFFFF">HIJKLMN</td>
    <td bgcolor="#FFFFFF" align="center">1</td>
    [End of Quote]

    The problem is, whatever the code is called in Page_Load or Page_Unload
    event, the HtmlWriter seems to stop writing somewhere less than 4400bytes,
    where the actual HTML length should be 4937 bytes. I measures this at the
    breakpoint stated in the enclosed code, by typing "? renderedPage.Length" in
    the command window.

    I've tried to increase the memory allocated to program, use byte[] to
    replace MemoryStream, using RenderControl instead of Render, etc. but with
    no luck.
    It seems to be the problem with Html32TextWriter.

    It's quite strange to me the place where it stopped because it's in the
    middle of a group of rows generated from the code on-the-fly. And the page
    shown on the browser rendered completely without problem.

    Does anyone have idea on why does it happen, or how to work around it? Any
    help would be appreciated.

    Thank you in advance.

    Regards,
    Lau Lei Cheong
    Lau Lei Cheong, May 15, 2004
    #1
    1. Advertising

  2. Some information to add:

    I've found that if I attach the "StreamWriter connected to the filestream"
    to the Html32TextWriter directly, then everything is Ok. So the problem
    should be on the MemoryStream.

    It's pity to find that because in my plan, the next thing to do is to try to
    write the content directly to the MailMessage.Body and send as HTML.

    Any help to workaround this would be appreciated.

    Regards,
    Lau Lei Cheong
    Lau Lei Cheong, May 15, 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. Replies:
    5
    Views:
    1,740
    Jonathan Bromley
    May 20, 2005
  2. Lewis Edward Moten III

    Slow Compile doesn't render complete page.

    Lewis Edward Moten III, Oct 23, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    353
    Jacob Yang [MSFT]
    Oct 25, 2003
  3. Justin Dutoit
    Replies:
    1
    Views:
    3,457
    Justin Dutoit
    Oct 5, 2004
  4. tshad

    Logon Page not using complete URL

    tshad, Oct 11, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    279
    Patrice
    Oct 11, 2006
  5. Glenn Gillen
    Replies:
    0
    Views:
    273
    Glenn Gillen
    Nov 17, 2006
Loading...

Share This Page