[英]ASP.NET MVC Render View to String
I'm currently using NVelocity to render some email templates. 我目前正在使用NVelocity呈现一些电子邮件模板。
I'm curious how I can do this with the standard ASP.NET MVC view engine ie render a view as a string. 我很好奇我如何使用标准ASP.NET MVC视图引擎来做到这一点,即将视图呈现为字符串。
Basically I want to pass get the string result of a model binded view and pass this to iTextSharp to generate a PDF. 基本上,我想传递获取模型绑定视图的字符串结果,并将其传递给iTextSharp以生成PDF。
Thanks. 谢谢。 Ben
本
You have a PDF generator that takes html as an arg to generate a pretty PDF? 您有一个将html作为arg生成漂亮PDF的PDF生成器?
Look at this blog entry for how to capture a rendered view as a string. 查看此博客条目 ,了解如何将呈现的视图捕获为字符串。
You can use a ContentResult to return Content(yourString, "text/plain"); 您可以使用ContentResult返回Content(yourString,“ text / plain”); but you just build the string in the ContentResult method and use no View.
但是您只是在ContentResult方法中构建字符串,并且不使用View。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.