c# - 如何将部分 View 呈现为字符串?

标签 c# asp.net asp.net-mvc asp.net-mvc-3 partial-views

如何从 Controller 或外部类库中的其他方法调用Html.Partial()方法?

我需要这样的东西:

string someView = "SomeView";
object someModel = new SomeModel();    
HtmlHelper helper = new HtmlHelper();    
string html = helper.Partial(someView, someModel).ToString();

我需要获取此方法返回的 html 字符串。

最佳答案

如果您想将部分 View 呈现为字符串,您可以使用此链接:Render a view as a string

但我认为你做错了什么......

关于c# - 如何将部分 View 呈现为字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11047198/

相关文章:

c# - 如何将 Nullable<T> 参数与 nHibernate Linq 表达式一起使用?

c# - 使用 MONO 降级 Web API 以在 Linux 上运行

c# - 发送多媒体指令

c# - 自动刷新 IIS 服务器上的缓存

Asp.Net 5(核心)RC1 : How to log to file (rolling file logging) [DNX Core 5 compatible solution]?

asp.net-mvc - 从业务逻辑类重定向asp.net mvc页面

C# - 将文件作为附件添加到 Microsoft.SharePoint.Client.ListItem (SharePoint 2010)

asp.net - JavaScript拼图: window. confirm = divConfirm(strMessage)

c# - ASP.NET 样板 - "The ObjectContext instance has been disposed"异常

c# - LINQ InvalidCastException 错误