I have case like: In MVC3 Razor, how do I get the html of a rendered view inside an action? but I'm using NancyFx.
Anybody known, how to do it?
I have case like: In MVC3 Razor, how do I get the html of a rendered view inside an action? but I'm using NancyFx.
Anybody known, how to do it?
I think, I find answare:
in http://shanemitchell.ca/tag/nancyfx/
in that method, the html is in "var content".
ViewLocationContext viewLocationContext = new ViewLocationContext()
{
Context = module.Context,
ModuleName = module.GetType().Name,
ModulePath = module.ModulePath
};
var rendered = module.ViewFactory.RenderView(viewName, model, viewLocationContext);
var content = "";
using (var ms = new MemoryStream())
{
rendered.Contents.Invoke(ms);
ms.Seek(0, SeekOrigin.Begin);
using (TextReader reader = new StreamReader(ms))
{
content = reader.ReadToEnd();
}
};