Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Quickly render a Sitecore Controller Rendering, using given Item as Datasource
public virtual HtmlString RenderItem(Item item, string controller, string action)
{
Assert.ArgumentNotNull(item, "item");
Assert.ArgumentNotNullOrEmpty(controller, "controller");
Assert.ArgumentNotNullOrEmpty(action, "action");
var r = new Rendering();
r.DataSource = item.Paths.FullPath;
using (RenderingContext.EnterContext(r))
{
var runner = new ControllerRunner(controller, action);
var result = runner.Execute();
return new HtmlString(result);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment