Created
March 7, 2013 13:02
-
-
Save bergquist/5107905 to your computer and use it in GitHub Desktop.
Render razorviews as strings.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using (var sw = new StringWriter()) { | |
| ViewEngineResult viewEngineResult = ViewEngines.Engines.FindPartialView(controllerContext, viewName); | |
| var viewContext = new ViewContext(controllerContext, viewEngineResult.View, viewData, new TempDataDictionary(), sw); | |
| viewEngineResult.View.Render(viewContext, sw); | |
| return sw.GetStringBuilder().ToString(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment