471,119 Members | 1,457 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,119 software developers and data experts.

Page.Render do not render complete page

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
Nov 18 '05 #1
1 1959
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
Nov 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Martin | last post: by
4 posts views Thread by Tony | last post: by
10 posts views Thread by Tim_Mac | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.