收到错误"视图在“〜/查看/页/ home.aspx'必须自ViewPage,与的ViewPage LT获得; TViewData>中ViewUserControl,或View

编程入门 行业动态 更新时间:2024-10-27 02:20:46
本文介绍了收到错误"视图在“〜/查看/页/ 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期货aspnet.$c$cplex/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 aspnet.codeplex/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;中V

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

    发布评论

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

    >www.elefans.com

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