我最近刚刚将我的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, string,string,object)'和 “Microsoft.Web.Mvc.ViewExtensions.RenderAction(System.Web.Mvc.HtmlHelper, string,string,object)'
我可以用以下两种选择中的任何一种替换该行来解决问题:
<% 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 }); %>
我应该使用哪两个,有什么区别?另外,有没有办法解决问题,而无需写入整个命名空间,就像我以前一样?
提前谢谢你。
答案 0 :(得分:4)
这是因为你还在引用旧的期货库,现在它已经被转移到主要的MVC库(Beta),你已经在两个地方得到了它。
如果您想修复它,请下载用于测试版的新期货库,并在项目中引用它而不是旧项目。
您可以在ASP.NET CodePlex网站找到它。
HTHS,
查尔斯