收到错误"视图在“〜/查看/页/ home.aspx'必须自ViewPage,与的ViewPage LT获得; TViewData>中ViewUserControl,或ViewUserControl< TViewData>" [英] Getting the error "The view at '~/Views/Page/home.aspx' must derive from ViewPage, ViewPage<TViewData>, ViewUserControl, or ViewUserControl<TViewData>"

查看:272
本文介绍了收到错误"视图在“〜/查看/页/ home.aspx'必须自ViewPage,与的ViewPage LT获得; TViewData>中ViewUserControl,或ViewUserControl< TViewData>"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚安装MVC2和我有看起来像这样的一个观点。

 <%@页标题=LANGUAGE =C#的MasterPageFile =〜/查看/共享/ Home.Master继承=System.Web.Mvc.ViewPage %GT;
< ASP:内容ID =内容1ContentPlaceHolderID =TitleContent=服务器>
    家
< / ASP:内容>
< ASP:内容ID =内容2ContentPlaceHolderID =日程地址搜索Maincontent=服务器>
    < H2>家庭和LT; / H>
< / ASP:内容>

和所述控制器被刚刚返回图。但是,当我运行该页面我得到这个错误:


  

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


  1. 复制MvcDiagnostics.aspx到Web项目的根目录。

  2. 重现错误。

  3. 重现错误后,去/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.

  1. Copy MvcDiagnostics.aspx to the root of your web project.
  2. Reproduce the error.
  3. 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屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆