By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,304 Members | 3,201 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,304 IT Pros & Developers. It's quick & easy.

Page.Render do not render complete page

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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.