本文介绍了无法将类型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>
但是这给了我错误:
据我所知,控制器的动作还可以,那么什么会给我这个错误?
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.
这篇关于无法将类型void隐式转换为对象. .NET MVC PartialViewResult的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!