I want to have an console application that I would use to render the output to a file.
Pseudocode:
ComponentBaseController controller = new ComponentBaseController();
SaveToFile("output.html", controller.Result);
I am not using real code here since I have tried different approaches, but nothing gets me near.
The closest I got using Tip # 25 from Stephen Walther, is this:
ComponentBaseController controller = new ComponentBaseController();
RouteData routeData = new RouteData();
routeData.Values.Add("controller", "ComponentBase");
var fakeContext = new FakeControllerContext(controller, routeData);
var result = controller.Details("klasta7") as PartialViewResult;
result.ExecuteResult(fakeContext);
Console.Write(fakeContext.HttpContext.Response.ToString());
This throws an System.InvalidOperationException that the partial view could not be found. Tried different locations for Views folder, but no luck.
Any ideas? Thanks!