当我尝试渲染其模型类型指定为的部分视图时:
@model dynamic
Run Code Online (Sandbox Code Playgroud)
使用以下代码:
@{Html.RenderPartial("PartialView", Model.UserProfile);}
Run Code Online (Sandbox Code Playgroud)
我得到以下异常:
'System.Web.Mvc.HtmlHelper<dynamic>' has no applicable method named 'RenderPartial' but appears to have an extension method by that name. Extension methods cannot be dynamically dispatched. Consider casting the dynamic arguments or calling the extension method without the extension method syntax.
Run Code Online (Sandbox Code Playgroud)
但是,.aspx文件中的相同代码完美无瑕.有什么想法吗?