【发布时间】:2011-01-28 04:58:37
【问题描述】:
我们需要将ActionResult 呈现为string 以将页面添加到我们的内部搜索引擎索引。我们选择了this solution to render to string。
我遇到了用于处理视图的ExecuteResult 调用问题。
代码片段:
var oldController = controllerContext.RouteData.Values["controller"];
controllerContext.RouteData.Values["controller"] =
typeof(TController).Name.Replace("Controller", "");
viewResult.ExecuteResult(controllerContext); // this line breaks
我收到以下错误:
"Object reference not set to instance of object" error.
我已经确认viewResult 不为空,所以必须在ExecuteResult 内部抛出异常。
我们可能缺少什么?
【问题讨论】:
-
Spark 提供开箱即用的渲染视图,减少摩擦。 :)
-
是的,但是将我们所有的视图移植到 Spark 中并不实际。
标签: c# .net asp.net-mvc viewrendering