在NancyFx Razor中,如何获取动作内渲染视图的html? [英] In NancyFx Razor, how do I get the html of a rendered view inside an action?
本文介绍了在NancyFx Razor中,如何获取动作内渲染视图的html?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
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:
在 http://shanemitchell.ca/tag/nancyfx/
在该方法中,html位于可变内容"中.
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();
}
};
这篇关于在NancyFx Razor中,如何获取动作内渲染视图的html?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文