public string GetViewHtml(Controller controller, string viewName, string masterName)
{
IView view = ViewEngines.Engines.FindView(controller.ControllerContext, viewName, masterName).View;
if (view == null) return "";
using (StringWriter writer = new StringWriter())
{
ViewContext viewContext = new ViewContext(controller.ControllerContext, view, controller.ViewData, controller.TempData, writer);
viewContext.View.Render(viewContext, writer);
return writer.ToString();
}
}
// 1 2 3
string htmlcode = GetViewHtml(this, "NewsInfo", "_Layout");