如何在运行时注入一个 ASP.MVC DLL 文件并调用它的动作?

How to inject an ASP.MVC DLL file at runtime and calls it's actions?

我正在开发 CMS,我需要将其模块化。所以我创建了一个名为 TestController 的简单控制器,其中包含一个名为 Index.

的动作

如何在运行时将该 DLL 文件注入主项目并在运行时呈现 TestControllerIndex 动作?

Html.Action returns MvcHtmlString,所以你应该可以这样做:

var html = Html.Action("MyAwesomeAction", new { foo = "bar" });