Asp – MVC Newbie Question about Strongly-Typed Views

asp.net-mvc

I think this is a namespace issue, and the answer is probably dead simple, but I'm new at this MVC stuff.

I have multiple views named "Index." This was not a problem until I tried to create a new, strongly-typed view named "Index."

(For what its worth, I'm trying to follow along with the steps in the NerdDinner sample, but in VB instead of C#.)

When I added the strongly-typed view named "Index," the compiler threw this error:

Base class 'System.Web.Mvc.ViewPage(Of
System.Collections.Generic.List(Of
Models.User))' specified for class
'Index' cannot be different from the
base class 'System.Web.Mvc.ViewPage'
of one of its other partial types.

Can someone enlighten me on why this is happening, and what I can do to alleviate the problem?

Thanks in advance.

VIEW:

<%@ Page Title="" Language="VB" MasterPageFile="~/Views/Shared/Site.Master" 
         AutoEventWireup="false" CodeBehind="Index.aspx.vb" 
         Inherits="SampleSite.Index" %> 
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server"> 
</asp:Content> 

Code Behind:

Imports System.Web.Mvc 
Imports System.Collections.Generic 

Partial Public Class Index Inherits System.Web.Mvc.ViewPage(Of List(Of SampleSite.Models.User)) 
End Class 

Best Answer

If you say you have multiple "Index pages" then the problem is that all have the same namespace. You have Index(a) derived from ViewPage and Index(b) derived from ViewPage of List(..), since the classes are declared partial and have equal namespaces the compiler tries to put them together in one class but is not possible since they don't inherit from the same base class.

Do this: Index (a) -> Inherits="SampleSite.Index" Index (b) -> Inherits="SampleSite.XXXXXXX.Index" and modify the code behind accordingly.