Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
658 views
in Technique[技术] by (71.8m points)

asp.net mvc - Error "The view at '~/Views/Page/home.aspx' must derive from ViewPage, ViewPage<TViewData>, ViewUserControl, or ViewUserControl<TViewData>"

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...