Skip to content

Instantly share code, notes, and snippets.

@herskinduk
Created April 23, 2016 12:34
Show Gist options
  • Save herskinduk/9c4294fe57f2ee2bfd2c6115a6543191 to your computer and use it in GitHub Desktop.
Save herskinduk/9c4294fe57f2ee2bfd2c6115a6543191 to your computer and use it in GitHub Desktop.
using Sitecore.Mvc.Helpers;
using Sitecore.Mvc.Pipelines;
using Sitecore.Mvc.Pipelines.Response.RenderRendering;
using Sitecore.Mvc.Presentation;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
namespace SUGCON16.Extensions
{
public static class SitecoreHelperExtension
{
public static HtmlString ControllerRendering(this SitecoreHelper helper, string controllerName, string actionName)
{
var rendering = new Rendering()
{
RenderingType = "Controller"
};
rendering["Controller"] = controllerName;
rendering["Controller Action"] = actionName;
rendering["Cacheable"] = "1";
// Cache_VaryBy...
// Datasource
var writer = new StringWriter();
var args = new RenderRenderingArgs(rendering, writer);
PipelineService.Get().RunPipeline("mvc.renderRendering", args);
return new HtmlString(writer.ToString());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment