I've got a snippet of code in a custom ActionResult
VB.NET Version
Dim result As New ViewResult()
开发者_C百科result.Model= data ## Property Model is ReadOnly
Return result
C# Version
ViewResult result = new ViewResult();
result.Model = data; // Property Model is ReadOnly
return result;
How do I properly return a View
from within a custom ActionResult
that can also include the model?
Setting
result.ViewData.Model = data;
Should help you. In fact, get ViewResultBase.Model
is implemented as
public object Model
{
get {
return ViewData.Model;
}
}
精彩评论