Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Created September 30, 2015 20:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bjoerntx/c8c1923044bdf3120b05 to your computer and use it in GitHub Desktop.
Save bjoerntx/c8c1923044bdf3120b05 to your computer and use it in GitHub Desktop.
public class HomeController : Controller
{
public ActionResult Index()
{
return View();
}
public ActionResult TemplateEditor()
{
var myString = RenderViewToString("Editor.aspx");
return Content(myString);
}
protected string RenderViewToString(string viewPath)
{
System.IO.StringWriter htmlStringWriter =
new System.IO.StringWriter();
Server.Execute(viewPath, htmlStringWriter);
return htmlStringWriter.GetStringBuilder().ToString();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment