错误“位于“〜/Views/Page/home.aspx"的视图必须派生自ViewPage,ViewPage< TViewData>,ViewUserContro

编程入门 行业动态 更新时间:2024-10-27 10:31:01
本文介绍了错误“位于“〜/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期货. .此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复制到Web项目的根目录.
  • 重现错误.
  • 重现该错误后,转到/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&am

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

    发布评论

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

    >www.elefans.com

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