无法将类型void隐式转换为对象. .NET MVC PartialViewResult
问题描述:
我有以下控制器操作:
[ChildActionOnly]
public virtual PartialViewResult ListActions(int id)
{
var actions = meetingActionRepository.GetAllMeetingActions(id);
return PartialView(actions);
}
以及以下操作链接(使用t4MVC和razor语法)
And the following action link (using t4MVC and the razor syntax)
<p>
@Html.RenderAction(MVC.MeetingActions.ListActions(Model.MeetingId))
</p>
但是这给了我错误:
无法将类型void隐式转换为对象
cannot implicitly convert type void to object
据我所知,控制器的动作还可以,那么什么会给我这个错误?
As far as i can tell the controller action is ok, so what could be giving me this error?
答
像这样:
<p>
@Html.Action(MVC.MeetingActions.ListActions(Model.MeetingId))
</p>
,或者如果您坚持这样使用RenderAction
:
or if you insist on RenderAction
like this:
<p>
@{Html.RenderAction(MVC.MeetingActions.ListActions(Model.MeetingId));}
</p>
我个人更喜欢第一个,使击键次数减少.
Personally I prefer the first, makes fewer keystrokes.