Skip to content

Instantly share code, notes, and snippets.

Created October 30, 2017 08:35
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Web;
using NewsletterStudio.Model;
using umbraco.BusinessLogic;
namespace NewsletterStudio.Services.RenderTasks.Tasks
public class RenderUrlRenderTask : RenderTask
public override void ProcessPreRender(RenderResult renderResult, RenderTaskParameters parameters)
Regex regex = new Regex(@"\[RenderUrl:([^]]*)\]");
renderResult.MessageBody = regex.Replace(renderResult.MessageBody, GetNiceUrl);
private static string GetNiceUrl(Match match)
string urlToDownload = match.Groups[1].Value;
// Get the content
string strReturn;
strReturn = Helper.DownloadWebPage(urlToDownload);
catch (Exception ex)
strReturn = string.Format("<div style='padding:10px; border: 1px dotted red;'>Could not load \"{0}\". Is the address correct?</div>", urlToDownload);
Log.Add(LogTypes.Error, 0, string.Format("RenderUrlRenderTask: {0}. Is the url ok? Are you sure that the application is allowed to download content from the internet?", ex));
return strReturn;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment