收到错误&QUOT;视图在“〜/查看/页/ home.aspx'必须自ViewPage,与的ViewPage LT获得; TViewData&gt;中ViewUserControl,或ViewUserControl&LT; TViewData&GT;&QUOT; [英] Getting the error "The view at '~/Views/Page/home.aspx' must derive from ViewPage, ViewPage<TViewData>, ViewUserControl, or ViewUserControl<TViewData>"
问题描述
我刚刚安装MVC2和我有看起来像这样的一个观点。
&LT;%@页标题=LANGUAGE =C#的MasterPageFile =〜/查看/共享/ Home.Master继承=System.Web.Mvc.ViewPage %GT;
&LT; ASP:内容ID =内容1ContentPlaceHolderID =TitleContent=服务器&GT;
家
&LT; / ASP:内容&GT;
&LT; ASP:内容ID =内容2ContentPlaceHolderID =日程地址搜索Maincontent=服务器&GT;
&LT; H2&GT;家庭和LT; / H&GT;
&LT; / ASP:内容&GT;
和所述控制器被刚刚返回图。但是,当我运行该页面我得到这个错误:
System.InvalidOperationException:在〜/查看/页/ home.aspx视图必须继承自ViewPage,的ViewPage,ViewUserControl或ViewUserControl派生
块引用>解决方案您可能会在无意中已加载到同一个应用程序的MVC框架的两个版本。为了证实,从下载MVC 2期货<一个href=\"http://aspnet.$c$cplex.com/releases/view/41742\">http://aspnet.$c$cplex.com/releases/view/41742.有这个ZIP文件的文件的 MvcDiagnostics.aspx
- 复制MvcDiagnostics.aspx到Web项目的根目录。
- 重现错误。
- 重现错误后,去/MvcDiagnostics.aspx,看看它是否抱怨(会以粗体红字)关于正在加载的框架的多个版本。该工具应建议一个解决方案,如果是这种情况。
不要忘了从项目中删除MvcDiagnostics.aspx当您完成。
I've just installed MVC2 and I've got a view that looks like this
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Home.Master" Inherits="System.Web.Mvc.ViewPage" %> <asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server"> Home </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> <h2>Home</h2> </asp:Content>
And the controller is just returning the view. But when I run the page I get this error:
System.InvalidOperationException: The view at '~/Views/Page/home.aspx' must derive from ViewPage, ViewPage, ViewUserControl, or ViewUserControl.
解决方案You might unintentionally have two versions of the MVC framework loaded into the same application. To confirm, download MVC 2 Futures from http://aspnet.codeplex.com/releases/view/41742. There is a file MvcDiagnostics.aspx in this ZIP file.
- Copy MvcDiagnostics.aspx to the root of your web project.
- Reproduce the error.
- After reproducing the error, go to /MvcDiagnostics.aspx and see if it complains (will be in bold red lettering) about multiple versions of the framework being loaded. The tool should suggest a resolution if this is the case.
Don't forget to delete MvcDiagnostics.aspx from your project when you are done.
这篇关于收到错误&QUOT;视图在“〜/查看/页/ home.aspx'必须自ViewPage,与的ViewPage LT获得; TViewData&gt;中ViewUserControl,或ViewUserControl&LT; TViewData&GT;&QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!