I recently updated my website to MVC 5. It ran well on my dev machine. when I moved to staging on shared hosting supporting .Net 4.0 where my MVC 4 site worked just fine. After deployment I received following exception.
Method not found: 'System.Web.WebPages.IDisplayMode
System.Web.Mvc.ControllerContext.get_DisplayMode()'.
I tried few things to troubleshoot issue but none helped.
My assumption is that .Net 4.5 & MVC 5.0 combination may not have this method.
My Assembly bindings.
<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-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
I faced the same issue while upgrading to MVC 5.
This was solved by removing Microsoft.Web.Mvc.FixedDisplayModes.dll. The dll is an old legacy fix for MVC4 and it can safely be removed when working with MVC5.
I got this solution from here: http://larre.fixstar.net/2014/10/sitecore-mvc-error-idisplaymode/
I would make sure that you followed all the steps in order to upgrade your project to MVC 5. Also, check the following:
Also, I believe MVC5 is .NET 4.5, not 4.0 (but I cannot find anywhere that lists the required .NET versions). If your host is .NET 4.0, this could also be an issue.
It could be that your shared hosting does not have these MVC 5 items installed in the GAC on the server. As a result, while MVC 4 worked, MVC 5 is failing because of bad assembly loads/matches.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With