Asp.net-mvc – Attempt by security transparent method ‘WebMatrix.WebData.PreApplicationStartCode.Start()’

asp.net-mvc

Update: same for mvc 4 to mvc 5.

I started a new mvc 4 project and migrated an mvc 3 project in it (controllers/models/scripts etc). While everything compiles now i get the following error:

Attempt by security transparent method 'WebMatrix.WebData.PreApplicationStartCode.Start()' to access security critical method 'System.Web.WebPages.Razor.WebPageRazorHost.AddGlobalImport(System.String)' failed.

I can't find anything on the web with this error. The error hits before getting into the application start.

I tried reinstalling all assemblies with nuget, putting a 'clean' web.config to no avail.

Anyone had this problem before?

Best Answer

For me this error was because I did NOT have Microsoft.AspNet.WebHelpers installed after updating from MVC 4 to MVC 5. It was fixed by installing the NuGet package

Install-Package -Id  Microsoft.AspNet.WebHelpers