错误“'~/Views/Page/home.aspx' 中的视图必须派生自 ViewPage、ViewPage<TViewData>、ViewUserControl 或 V

编程入门 行业动态 更新时间:2024-10-27 04:24:44
本文介绍了错误“'~/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 框架加载到同一个应用程序中.要确认,请从 aspnet.codeplex/releases/view/41742 下载 MVC 2 Futures.此 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 aspnet.codeplex/releases/view/41742. There is a file MvcDiagnostics.aspx in this ZIP file.

  • 将 MvcDiagnostics.aspx 复制到您的网络项目的根目录.
  • 重现错误.
  • 重现错误后,转到/MvcDiagnostics.aspx 并查看它是否抱怨(以粗体红色字体显示)正在加载多个版本的框架.如果是这种情况,该工具应建议解决方案.
  • 完成后不要忘记从项目中删除 MvcDiagnostics.aspx.

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

    更多推荐

    错误“'~/Views/Page/home.aspx' 中的视图必须派生自 ViewPage、ViewPage<TViewData>

    本文发布于:2023-11-10 00:32:30,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1573866.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:视图   错误   Page   home   Views

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!