asp.net - mvc 在没有 httpContext 或 Controller 上下文的情况下渲染部分 View

标签 asp.net asp.net-mvc asp.net-mvc-3 razor asp.net-mvc-4

是否可以在没有 ViewContext 或 ControllerContext 的情况下渲染部分 View ?

  • 我正在尝试从 Controller 操作外部获取 PartialView Html 作为字符串。
  • 是否可以从其他方法调用 Controller 操作? (这将允许我执行 Controller 操作并以这种方式获取部分 View html)。

最佳答案

您可以尝试Razor Generator Visual Studio 扩展。基本上,您在 View 上运行自定义工具,它将生成一个可以将模型传递到其中的类,并且它将生成一个字符串。

关于asp.net - mvc 在没有 httpContext 或 Controller 上下文的情况下渲染部分 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15896703/

相关文章:

asp.net - 在我的 VS 2013 环境中获取 ASP.NET 4.5(安装或升级)

javascript - 两个 jQuery/JavaScript 函数未被调用

c# - 如何读取 MVC Mini Profiler 中的步骤时间?

c# - 在 C# 的 LINQ 中按多列分组

c# - MVC3 : How to change the generic [Required] validation message text?

c# - 在 .NET(非 MVC)中访问数据的最佳实践

asp.net - msdeploy 和 web 部署有什么区别?

c# - 单击按钮时隐藏 Gridview 行

asp.net-mvc-3 - 在 MVC 中的 Http Post 之后渲染相同的 View

c# - 如何在 ASP.net MVC 的文件夹中显示保存的图像