Upgrade MVC 2 to MVC 3 issues with views
I'm attempting to upgrade my existing ASP.net MVC 2 web application to MVC 3 so I can use the goodness that is the Razor Viewengine and other said improvements.
After using the converter to convert my app from mvc2 to mvc3 I'm having issues with my strongly typed views. As an example here we have a view user control that is strongly typed to the class Profile
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<Profile>" %>
During compilation I'm getting
Compiler Error Message: CS1061: 'object' does not contain a definition for 'folio' and no extension method 'folio' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly开发者_开发知识库 reference?)
which corresponds to this line in my view
So it's like the views are no longer accepting a type. This is happening w/ user controls as well as full on views.
I've checked both web.config and views/web.config and both seem to be referencing System.Web.Mvc version 3.0.0.0
Any help would be appreciated!
See below for screen captures of web.configs
This is a bug in MVC 3 Preview 1, and will be addressed in the next release. In the interim, you can rearrange your pages so that the <%@ Control %> directive is the last one in the file and that should the issue for you.
I simply replaced the web.config in my 'Views' folder (with one from a newly created mvc3 project) as the migration suggested and it worked for me. I wasn't prepared to move all the declarations to the bottom as my project was just too big.
Hope it helps although this is probably too late for you. Maybe it helps others...
On the off chance try changing your bindingRedirect
to
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="3.0.0.0" />
I had the exact same problem and after pulling my hair out a bit, found and followed Wiaan's solution. Worked perfectly, and the site is back up.
Funny enough not making this change on our dev boxes did not break our site - it was only when we moved it to a staging server that it surfaced.
If your project is based on MVC4 or using Framwork 4 already, create mvc4 empty project. And then replace web.config in views folder. It works immediately. Thanks, Wianne. Since I have kind of old app that used aspx rather than razor. After I upgraded Framework 3 to 4, I got this error.
精彩评论