错误“位于“〜/Views/Page/home.aspx"的视图必须派生自ViewPage,ViewPage< TViewData>,ViewUserControl或ViewUserControl< TViewData>". [英] Error "The view at '~/Views/Page/home.aspx' must derive from ViewPage, ViewPage<TViewData>, ViewUserControl, or ViewUserControl<TViewData>"

查看:114
本文介绍了错误“位于“〜/Views/Page/home.aspx"的视图必须派生自ViewPage,ViewPage< TViewData>,ViewUserControl或ViewUserControl< TViewData>".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚安装了MVC2,并且具有这样的视图

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:〜/Views/Page/home.aspx"上的视图必须派生自ViewPage,ViewPage,ViewUserControl或ViewUserControl.

System.InvalidOperationException: The view at '~/Views/Page/home.aspx' must derive from ViewPage, ViewPage, ViewUserControl, or ViewUserControl.

推荐答案

您可能无意中将两个版本的MVC框架加载到同一应用程序中.要确认,请从 http://aspnet.codeplex.com/releases/view/41742下载MVC 2期货. .此ZIP文件中有一个文件 MvcDiagnostics.aspx .

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. 将MvcDiagnostics.aspx复制到Web项目的根目录.
  2. 重现错误.
  3. 重现该错误后,转到/MvcDiagnostics.aspx,查看它是否抱怨(将以红色粗体显示)有关正在加载的框架的多个版本.在这种情况下,该工具应建议一个解决方案.

完成后,请不要忘记从项目中删除MvcDiagnostics.aspx.

Don't forget to delete MvcDiagnostics.aspx from your project when you are done.

这篇关于错误“位于“〜/Views/Page/home.aspx"的视图必须派生自ViewPage,ViewPage&lt; TViewData&gt;,ViewUserControl或ViewUserControl&lt; TViewData&gt;".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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