1

我最近刚刚将我的 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 }); %>

我应该使用两者中的哪一个,有什么区别?另外,有没有什么方法可以解决问题而不像我以前那样写整个命名空间?

先感谢您。

4

1 回答 1

4

这是因为您仍在引用旧的期货库,并且现在它已被转移到主 MVC 库(Beta),您已经在两个地方获得了它。

如果您想修复它,请下载与 beta 版本一起使用的新期货库,并在您的项目中引用该库而不是旧库。

您可以在ASP.NET CodePlex站点上找到它。

HTH,
查尔斯

于 2009-11-26T01:11:47.430 回答