所以我刚刚将我的网站从 MVC 3 升级到 MVC 4 网站。我的 Web 主机没有安装 MVC 4,但有人建议我只需上传 dll,一切都会好起来的。我被定向到此链接,显然可以在安装时应用
我按照以下链接中的指示进行操作,但随后我的 ViewExtensions 出现错误,这显然(经过 2 小时的研究)与我的升级有关(例如 http://s77.codeinspot.com/q/2109234 )。无论如何,这是抛出的错误。
filterContext.Exception.Message :\hostingpath............... error CS0121: The call is ambiguous between the following methods or properties: 'Torneyo.Infrastructure.Helpers.ViewExtensions.AccountProfile(System.Web.Mvc.ViewMasterPage)' and 'Torneyo.Infrastructure.Helpers.ViewExtensions.AccountProfile(System.Web.Mvc.ViewMasterPage)'
这没有意义,因为它是相同的,并且它只是来 self 的 viewextension 类。以下是在我的母版页上调用的部分。
//-----------for master pages
static public User AccountProfile(this System.Web.Mvc.ViewMasterPage view)
{
return (Profile)view.ViewBag.AccountProfile;
}
因此,在网络主机升级之前,这些都运行得很好。升级前后它在我的本地运行完美。我不太确定我还需要做什么。
最佳答案
请确保您的 web.config 中有正确的绑定(bind)重定向。应用程序的某些部分很可能引用 MVC3,而其他部分则引用 MVC4。从 MVC3 到 MVC4 的绑定(bind)重定向会将所有内容“统一”到 MVC4。
在此处查看“升级”指南:http://www.asp.net/whitepapers/mvc4-release-notes#_Toc303253806
关于asp.net-mvc - 未安装 mvc 4 的 Web 服务器上的 mvc 4 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15629178/