Error generating macroContent: 'System.Web.HttpException (0x80004005): Error executing child request for /default.aspx. ---> System.Web.HttpUnhandledException (0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.Web.HttpException (0x80004005): Server cannot append header after HTTP headers have been sent.
I'm struggling with the exact same problem and I would LOVE to make some progress.
I'm messing around with Nibble's Mass Mailer package (modified as per the third to last comment to make it work under Umbraco 4.5+ / .NET 4.0).
For reasons unbeknownst to man the "Send single e-mail" function works as a charm, while the "Send mass e-mail" doesn't fail but sends an e-mail containing the stack trace of the above mentioned error.
Here's the string that's returned:
System.Web.HttpUnhandledException (0x80004005): Exception of type
'System.Web.HttpUnhandledException' was thrown. --->
System.Web.HttpException (0x80004005): Server cannot append header after
HTTP headers have been sent. at
System.Web.HttpResponse.AppendHeader(String name, String value) at
umbraco.UmbracoDefault.OnInit(EventArgs e) at
System.Web.UI.Control.InitRecursive(Control namingContainer) at
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at
System.Web.UI.Page.HandleError(Exception e) at
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at
System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint,
Boolean includeStagesAfterAsyncPoint) at
System.Web.UI.Page.ProcessRequest() at
System.Web.UI.Page.ProcessRequest(HttpContext context) at
System.Web.HttpServerUtility.ExecuteInternal(IHttpHandler handler,
TextWriter writer, Boolean preserveForm, Boolean setPreviousPage,
VirtualPath path, VirtualPath filePath, String physPath, Exception
error, String queryStringOverride) at
System.Web.HttpServerUtility.ExecuteInternal(IHttpHandler handler,
TextWriter writer, Boolean preserveForm, Boolean setPreviousPage,
VirtualPath path, VirtualPath filePath, String physPath, Exception
error, String queryStringOverride) at
System.Web.HttpServerUtility.Execute(String path, TextWriter writer,
Boolean preserveForm) at umbraco.library.RenderTemplate(Int32 PageId)'
-->
I've been scouring through Tim's source code and I cannot for the life of me figure out why "Single" should work and "Mass" not.
Unfortunately it's the exact same prolem as Medjeti. I have been elaborating on the Mass Mailer to fix various problems and it has been working fine until 4.6.1 but now it fails. I took out the code from the Umbraco library and found the error in the code line showed in my first post
The error seems to occur when Library.SendMailFromPageToMember() is called from the ProgressBar1_RunTask() event handler (not btnSendMass_Click() as you'd think).
This is the handler for the EO.Web progress bar, which apparently does some flushing / respons'ing back and forth which causes RenderTemplate() to break.
A temporary solution seems to be: Remove the <eo:ProgressBar> tag (mailing.aspx, line 189) - this will cause the dialog to do a proper post-back instead of the Ajax stuff. The post-back will be handled from the btnSendMass_Click() event handler which seems to work.
I haven't tested this thoroughly at all, but it seemed to work late last night. Gimme a shout when you fixed it and have a working build to share :o)
As far as I can gather, using the <eo:ProgressBar> overrides the post-back event and uses the ProgressBar1_RunTask() event handler instead of btnSendMass_Click().
For some reason, calling RenderTemplate() from ProgressBar1_RunTask() doesn't work, so I've found that you need to disable the <eo:ProgressBar> in order for the btnSendMass_Click() logic to kick in.
This means you won't have your nice progress bar, but at least you'll have a functioning mail script.
I thought the progress bar was worth fighting for so I finally found a solution.
I did this in Page_load
int pageId = int.Parse(Request["id"], CultureInfo.InvariantCulture); string body = umbraco.library.RenderTemplate(pageId); HttpContext.Current.Cache.Insert("body", body);
and then this in ProgressBar1_RunTask
if (HttpContext.Current.Cache["body"] == null) throw new InvalidOperationException("No boy was created"); string mailBody = HttpContext.Current.Cache["body"].ToString();
Then I avoid the RenderTemplate in the ProgressBar1_RunTask.
My MailEingine doesn't look quiet as the original one - I did some rewriting to come around danish characters and resource problems
Yes unfortunately which is a PITA for others when you end up answering your own question because you can't mark the real solution for the benefit of others.
Sorry to revive an old thread but I just encountered the (apparently well-known) encoding issue regarding Danish / non-ascii characters.
I added the BodyEncoding and SubjectEncoding properties as per your example - things are fine in desktop clients such as Outlook, but webmail clients seem to act up. Did you - or anybody else - manage to resolve this?
Your trick deleting <eo:ProgressBar /> worked fine. However Paul's solution is not clear to me. Did you test Paul's solution? If so, could you please post the entire mailing.aspx as well as mailing.aspx.cs? You'd really help me out on that.
Thanks a lot, this worked like a charm! I had to alter lines107-109 Library.cs as well from:
public static void SendMailFromPageToMember(string FromMail, Member member, string Subject, int PageId) { string body = umbraco.library.RenderTemplate(PageId);
to:
public static void SendMailFromPageToMember(string FromMail, Member member, string Subject, string body) { //string body = umbraco.library.RenderTemplate(PageId);
The character problem - in Dutch we use some special characters, for instance: ë - I solved by setting everything to UTF-8. This means adding this metaline to the newsletter's template as well:
RenderTemplate problem - Error generating macroContent
Hi
After upgrading to 4.6.1 I suddenly have this problem with RenderTemplate. I'm pretty sure the problem comes in this line of code
Context.Server.Execute(string.Format("/default.aspx?umbPageID={0}{1}", PageId, queryString), sw);
Hi Paul,
Where are you calling RenderTemple from? I found that I couldn't use it within XSLT macros - but it worked fine from a user-control macro.
Cheers, Lee.
Hey guys,
I'm struggling with the exact same problem and I would LOVE to make some progress.
I'm messing around with Nibble's Mass Mailer package (modified as per the third to last comment to make it work under Umbraco 4.5+ / .NET 4.0).
For reasons unbeknownst to man the "Send single e-mail" function works as a charm, while the "Send mass e-mail" doesn't fail but sends an e-mail containing the stack trace of the above mentioned error.
Here's the string that's returned:
I've been scouring through Tim's source code and I cannot for the life of me figure out why "Single" should work and "Mass" not.
Any ideas are greatly appreciated!
Hi
Unfortunately it's the exact same prolem as Medjeti. I have been elaborating on the Mass Mailer to fix various problems and it has been working fine until 4.6.1 but now it fails. I took out the code from the Umbraco library and found the error in the code line showed in my first post
/Paul S
Well, I've made a bit of headway:
The error seems to occur when Library.SendMailFromPageToMember() is called from the ProgressBar1_RunTask() event handler (not btnSendMass_Click() as you'd think).
This is the handler for the EO.Web progress bar, which apparently does some flushing / respons'ing back and forth which causes RenderTemplate() to break.
A temporary solution seems to be: Remove the <eo:ProgressBar> tag (mailing.aspx, line 189) - this will cause the dialog to do a proper post-back instead of the Ajax stuff. The post-back will be handled from the btnSendMass_Click() event handler which seems to work.
I haven't tested this thoroughly at all, but it seemed to work late last night. Gimme a shout when you fixed it and have a working build to share :o)
Hi
I don't quiet follow you here unless you mean just call the logic in the eventhandler for the ProgressBar1_RunTask
If you mean something else could you please clarify
/Paul S
Hey Paul,
As far as I can gather, using the <eo:ProgressBar> overrides the post-back event and uses the ProgressBar1_RunTask() event handler instead of btnSendMass_Click().
For some reason, calling RenderTemplate() from ProgressBar1_RunTask() doesn't work, so I've found that you need to disable the <eo:ProgressBar> in order for the btnSendMass_Click() logic to kick in.
This means you won't have your nice progress bar, but at least you'll have a functioning mail script.
Hope that's a bit more clear... :o)
Hi
I thought the progress bar was worth fighting for so I finally found a solution.
I did this in Page_load
Hey Paul,
Fantastic work, thanks for sharing!
Can you elaborate on the character problems you had? Easy to fix?
Here's my Send method
Hope you can use it - and thanks for your assistance
/Paul S
Excellent, thanks for sharing - you rock! :o)
You may want to mark your topic as resolved for future reference.
How do I mark it as resolved?
/Paul S
Click the tick on the post that you want to mark as the solution.
Simon
Thanks finally got it - has to be on a respons from someone else then me
/Paul S
Yes unfortunately which is a PITA for others when you end up answering your own question because you can't mark the real solution for the benefit of others.
Hey Paul,
Sorry to revive an old thread but I just encountered the (apparently well-known) encoding issue regarding Danish / non-ascii characters.
I added the BodyEncoding and SubjectEncoding properties as per your example - things are fine in desktop clients such as Outlook, but webmail clients seem to act up. Did you - or anybody else - manage to resolve this?
Cheers,
/Mikael
@Medjeti:
Your trick deleting <eo:ProgressBar /> worked fine. However Paul's solution is not clear to me. Did you test Paul's solution? If so, could you please post the entire mailing.aspx as well as mailing.aspx.cs? You'd really help me out on that.
Tnx in advance!
@Medjeti:
I have no problems in with the danish characters in the mails I produce when reading them in ex. Google mail.
/Paul S
@Paul: I see now Gmail displays the characters correctly, however one.com webmail does not. Oh well, one of those things I guess...
@Patrick: I didn't take time to tidy things up, so it's not exactly pretty - but at least it works...
http://dl.dropbox.com/u/4147537/mailing.aspx
http://dl.dropbox.com/u/4147537/mailing.aspx.cs
Did you update the project referencing the .NET 4.0 version of EO.Web? Check happyfanaticsalser'c omment on http://www.nibble.be/?p=63 ;
Hope that helps!
/Mikael
@Medjeti:
Thanks a lot, this worked like a charm! I had to alter lines107-109 Library.cs as well from:
to:
The character problem - in Dutch we use some special characters, for instance: ë - I solved by setting everything to UTF-8. This means adding this metaline to the newsletter's template as well:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
@Medjeti:
can you post the files again?:) the links above doesn't work anymore
Thanks :)
Yup yup, files are back up.
is working on a reply...