我在自定义ActionResult中有一段代码
VB.NET版本
Dim result As New ViewResult()
result.Model= data ## Property Model is ReadOnly
Return result
C#版
ViewResult result = new ViewResult();
result.Model = data; // Property Model is ReadOnly
return result;
如何从可以包含模型的自定义View
中正确返回ActionResult
?
答案 0 :(得分:3)
设置
result.ViewData.Model = data;
应该帮助你。事实上,get ViewResultBase.Model
实现为
public object Model
{
get {
return ViewData.Model;
}
}