I am implementing an offline html to pdf printing function. I want to get the html that would be returned by a view and save it to a file on the server side.
public JsonResult MyReportOfflinePrint(MyParameters p)
{
ActionResult res = MyReportPrintMethod(p);
using (StreamWriter sw = new StreamWriter("myreport.html")) {
sw.Write(res.GetTheHtmlString???)
}
return Json("it worked");
I could use http as a web service and call self, but since this view is already available in the same controller that seems like a waste.
I have seen questions about calling a different controller, and returning a raw string as a view, but I want to capture the html string produced by razor engine.