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 http://aspnet.codeplex.com/releases/view/41742. There is a file MvcDiagnostics.aspx in this ZIP file.
Don't forget to delete MvcDiagnostics.aspx from your project when you are done.
I was getting this error upgrading my MVC 1.0 project to MVC 2.0. If you are doing this have a look at http://weblogs.asp.net/leftslipper/archive/2010/03/10/migrating-asp-net-mvc-1-0-applications-to-asp-net-mvc-2-rtm.aspx
Double check your web.config against a new MVC 2.0 project.
Doing either a batch->build->clea
n at the solution level OR a clean at the project level usually takes care of this if you have already done the due diligence of removing/replacing the undesired version(s) of System.Web.Mvc
from project references and *.config files...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With