Updating Razor 2.0 to 3.0 with Asp.net MVC
Currently updating an application from Asp.net MVC 4.0 to MVC 5.0 but before I update MVC I wanted to update the Razor package. Since the MVC package is dependent on the Razor. So this article is about Razor 2 to Razor 3 and the problems I faced.
Razor in my opinion
Razor 3.0 (details in the link) is an awesome package in my opinion and I shudder to think anyone who writes Asp.net MVC applications using ASPX. For me the Razor syntax is an effective way to write visually clean code and because of this provide very low maintenance.
Issues with Razor Updating from 2.0 to 3.0
As I updated I encounter numerous problem with the Razor package from 2.0 to 3.o and not only did it break my application but destroyed the Intellisense for Razor (mostly for ViewBags).
So for my first problem...
Razor in my opinion
Razor 3.0 (details in the link) is an awesome package in my opinion and I shudder to think anyone who writes Asp.net MVC applications using ASPX. For me the Razor syntax is an effective way to write visually clean code and because of this provide very low maintenance.
Issues with Razor Updating from 2.0 to 3.0
As I updated I encounter numerous problem with the Razor package from 2.0 to 3.o and not only did it break my application but destroyed the Intellisense for Razor (mostly for ViewBags).
So for my first problem...
Inheritance security rules violated by type: 'System.Web.WebPages.Razor.WebPageRazorHost'. Derived types must either match the security accessibility of the base type or be less accessible.
Which could not be resolved by the solution listed in the reference, however after doing some research I found my answer in the update release notes. The "Removal of security transparent attribute. Note: This is a breaking change, and makes Razor 3 incompatible with MVC4 and earlier, while Razor 2 is incompatible with MVC5 or assemblies compiled against MVC5".
I think in the future when breaking changes happen to list the dependences in even a package with no previous dependencies. It should list the package level requirements of others, which would be the whole point of a dependency and my confusion for is this error only appearing in the release notes but I can see why it may not be listed either since a package that has requirements gets checked for all its dependencies and since MVC require Razor this might create an infinite loop.
After Updating MVC4 to MVC5 use this snippet of code from the release notes...
<dependentAssembly> <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" /> <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="3.0.0.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" /> <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="3.0.0.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Web.WebPages.Razor" publicKeyToken="31bf3856ad364e35" /> <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" /> <bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="5.0.0.0" /> </dependentAssembly>
Which resolved most of my issues for Razor. So Update MVC4 to MVC5... and if you have troubles feel free to leave a comment.