This answer is based on the advice Bertrand gave me, but I wanted to put it together with what I found.
In order to be able to use FindPartialView, I needed to inject an instance of IViewEngineProvider into my controller.
Then I used the following code to resolve and render the view:
private String RenderView(String viewName, object model) { var paths = new List<string>(); // This can just be an empty list and it still finds it. var viewEngine = _viewEngineProvider.CreateModulesViewEngine(new CreateModulesViewEngineParams {VirtualPaths = paths}); var viewResult = viewEngine.FindPartialView(ControllerContext, viewName, false); if (viewResult.View == null) { throw new Exception("Couldn't find view " + viewName); } var viewData = new ViewDataDictionary {Model = model}; using (var sw = new StringWriter()) { var viewContext = new ViewContext(ControllerContext, viewResult.View, viewData, TempData, sw); viewResult.View.Render(viewContext, sw); return sw.GetStringBuilder().ToString(); } }
source share