Attempt by security transparent method 'System.Web.WebPages.Administration.SiteAdmin.RegisterAdminModule()' to access security critical method failed

For me this happened when i went to VS 2015. It seems that the system.web.webpages.administration.dll was remaining in the bin folder and this caused a problem. this happened when I upgraded some NUGet packages. I am unsure to which one. I deleted the .dll and this fixed the issue for me. I noticed when i reinstalled the web helpers it seemed to come back, so maybe that is the offending package? Edit: I wanted to add that I did not find the dependency in the vbproj file in my case. I could find nowhere that my project used this .dll but all the same it seems to load up.


Just incase if anyone faced this issue when publishing the app to Azure app service

  1. Go to settings in the publishing profile enter image description here

    1. check the checkbox "Remove additional files at destination" enter image description here

Try this:

comment below two lines in site.csproj file

<!--<None Iclude="_bin_deployableAssemblies\System.Web.WebPages.Administration.dll" />-->

<Content Include="App_Data\XmlDocument.xml" />