DinnerController issue

Apr 4, 2011 at 4:44 PM


I am trying to learn MVC by going thru NerdDinner

I have this code in my DinnersController

 Function Index() As ActionResult          
        Dim dinners = dinnerRepository.FindUpcomingDinners().ToList() 'As DinnerRepository             

Return View("Index", dinners)                    

End Function

and i get this error:

The model item passed into the dictionary is of type 'System.Data.Linq.DataQuery`1[NerdDinner.Dinner]', but this dictionary requires a model item of type 'NerdDinner.Dinner'.



Apr 5, 2011 at 4:21 PM

In your \Views\Dinners\Index.aspx View, what is the <%@ Page Inherits property value? Based on the error message I would suspect that it's System.Web.Mvc.ViewPage<NerdDinner.Models.Dinner> . Since it looks like you're using VB maybe it's System.Web.Mvc.ViewPage(Of NerdDinner.Models.Dinner).

You're passing it a List of Dinners, so it should be something more like System.Web.Mvc.ViewPage(Of NerdDinner.Helpers.PaginatedList(Of NerdDinner.Models.Dinner))

Give that a try and see if it helps.