In NancyFx Razor, how do I get the html of a rendered view inside an action?

佐手、 提交于 2019-12-11 03:43:53

问题


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?


回答1:


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();
            }
        };


来源:https://stackoverflow.com/questions/25847218/in-nancyfx-razor-how-do-i-get-the-html-of-a-rendered-view-inside-an-action

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!