I've been using ASP.NET MVC since preview 1, and have loved every bit of it. Between preview releases, none of my code broke -- even between 2 and 3... Wait that can't be right...
So when the MVC beta dropped recently, I went ahead and upgraded my three projects. Little did I know that when I was upgrading all of those other times, I was forgetting to update my assembly references! Big d'oh! I had been using preview 2 this whole time!
Upgrading from preview 2 to the beta can be a bit of a pain, so here are some hints to make the process easier, if anyone out there actually needs to do this.
In pages/namespaces: <add namespace="System.Web.Mvc.Html" />
Happy coding!
So when the MVC beta dropped recently, I went ahead and upgraded my three projects. Little did I know that when I was upgrading all of those other times, I was forgetting to update my assembly references! Big d'oh! I had been using preview 2 this whole time!
Upgrading from preview 2 to the beta can be a bit of a pain, so here are some hints to make the process easier, if anyone out there actually needs to do this.
- Update your strongly typed ViewData references to use ViewData.Model - This one is pretty self-explanitory. If you have strongly typed ViewData (by typing ViewData<Foo> in your codebehind) you need to reference ViewData.Model in your views now.
- ViewData is now ViewDataDictionary - If you have custom ViewData-derived classes, you should change them to inherit ViewDataDictionary. I just got rid of mine completely and created some ViewInfo classes to pack up all the common data I needed to send over that wasn't my model object.
- RenderView("Page") is now return View("Page") - Much, much nicer. Make sure you change those public voids to public ActionResults as well. Good work on this change!
- Default.aspx has a codebehind page now - If you're getting blank pages, you probably want to update your Default.aspx that is included in the project template. Just create a new MVC beta project and you should have it ready to copy into your old project.
- Update your Web.config file - There are a few new entries:
In pages/namespaces: <add namespace="System.Web.Mvc.Html" />
Happy coding!
