我最近刚刚将我的 ASP.Net MVC 项目从 MVC 2.0 Preview 2 迁移到 MVC 2.0 Beta,我对 Html.RenderAction 的调用中断了,因为在 MVC 2.0 Beta 中引入了一个新的 RenderAction 方法。
在以下行中:
<% Html.RenderAction("DisplayIMHandles", "UserProfile", new { userProfileId = Model.Id }); %>
我收到以下错误:
编译器错误消息:CS0121:以下方法或属性之间的调用不明确:
'System.Web.Mvc.Html.ChildActionExtensions.RenderAction(System.Web.Mvc.HtmlHelper,字符串,字符串,对象)'和'Microsoft.Web.Mvc.ViewExtensions.RenderAction(System.Web.Mvc.HtmlHelper,字符串,字符串,对象)'
我可以通过用以下两种替代方法中的任何一种替换该行来解决问题:
<% Microsoft.Web.Mvc.ViewExtensions.RenderAction
(this.Html, "DisplayIMHandles", "UserProfile", new { userProfileId = Model.Id }); %>
或者
<% System.Web.Mvc.Html.ChildActionExtensions.RenderAction
(this.Html, "DisplayIMHandles", "UserProfile", new { userProfileId = Model.Id }); %>
我应该使用两者中的哪一个,有什么区别?另外,有没有什么方法可以解决问题而不像我以前那样写整个命名空间?
先感谢您。