Unlimited .NET MVC Link Type

Not quite sure what is going on here; Any help would be appreciated.

I am trying to create a new .NET MVC web application. I was sure that I configured it correctly, but I get the following error:

The type 'System.Web.Mvc.ViewPage' is ambiguous: it could come from assembly 
'C:\MyProject\bin\System.Web.Mvc.DLL' or from assembly 
'C:\MyProject\bin\MyProject.DLL'. Please specify the assembly explicitly in the type name.

The original error he reports is as follows:

Line 1:  <%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>
Line 2:  
Line 3:  <asp:Content ID="indexContent" ContentPlaceHolderID="MainContentPlaceHolder" runat="server">

Something great that I'm completely wrong?

+5
source share
9 answers

I suppose you called one of your pages "ViewPage", is that the case?

And, as Jonathan said, it smells:

Inherits="System.Web.Mvc.ViewPage"

In my MVC application, all view pages have this:

Inherits="MySite.Views.Pages.Home"

- . aspx "", , , . , .

+3

CodeBehind, CodeBehind = "", Inherits? codebehind.

:

<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" AutoEventWireup="true" CodeBehind="Index.aspx.cs" Inherits="MvcApplication4.Views.Home.Index" %>

, Inherits . , .

+2

- ASP.NET MVC .

, . "CodeBehind" @Page "Inherits", System.Web.Mvc.ViewPage, aspx.cs , .

, , .

, aspx.cs(code behind) .

+2

System.Web.Mvc web.config.

Mine 2.0.0.0, 3.0.0.0

+2

. , . , .

+1
 Inherits="System.Web.Mvc.ViewPage"

, View codebehind, ViewPage.

+1

C:\MyProject\bin\MyProject.DLL ViewPage, , .

+1

I had the same mistake this week.

My Webform.aspx file had a generated designer.cs file. In this file, the class was actually named "ViewPage". Delete the constructor file or move the contents of the class to the webform.aspx.cs file and my error went away.

Just put it there if someone had this error.

0
source

All Articles