views:

97

answers:

2

I had a functioning ASP.NET MVC 1.0 Project with strongly typed views. They no longer function after upgrading to ASP.NET MVC 2.0 Preview 2.

The Model property now is an Object instead of the requested type.

I have this:

<%@ Language="C#" 
    Inherits="System.Web.Mvc.ViewUserControl<IEnumerable<TechHelp.Core.Models.Ticket>>" %>

I get

CS1579: foreach statement cannot operate on variables of type 'object' because 'object' does not contain a public definition for 'GetEnumerator'

Edit does anyone have any idea why this wouldn't be working?

A: 

We had the same thing in ASp.Net MVC2 (the released version). All strongly typed views thought that they worked on type "Object" in defiance of the declaration at the top of the file. If the views were compiled upfront, they failed to compile. If not, they failed when the page was accessed.

The project was in VS2010 and Asp.Net 2.0, originally upgraded from VS2008 and ASP.Net 1.0. A new Asp.Net MVC project did not have the same issues, but upon copying the code into a new solution, the same issues surfaced again.

The cause is that the upgrade process has changed the project's references from ASP.Net MVC 1.0 to ASP.Net MVC 2.0, but the web.config files were still referring to ASP.Net MVC 1.0. Updating these to match as per the instructions and adding in the bindingRedirect solved it.

Anthony