HttpException (0x80004005): The pre-application start initialization method Start on type System.Web.WebPages.Administration.PreApplicationStartCode threw an exception

Cacenco, Michael 0 Reputation points
2026-08-25T15:41:52.64+00:00

Stack Trace:

[MethodAccessException: Attempt by security transparent method 'System.Web.WebPages.Administration.SiteAdmin.RegisterAdminModule()' to access security critical method 'System.Web.WebPages.ApplicationPart..ctor(System.Reflection.Assembly, System.String)' failed.]

System.Web.WebPages.Administration.SiteAdmin.RegisterAdminModule() +64

[InvalidOperationException: The pre-application start initialization method Start on type System.Web.WebPages.Administration.PreApplicationStartCode threw an exception with the following error message: Attempt by security transparent method 'System.Web.WebPages.Administration.SiteAdmin.RegisterAdminModule()' to access security critical method 'System.Web.WebPages.ApplicationPart..ctor(System.Reflection.Assembly, System.String)' failed..]

System.Web.Compilation.BuildManager.InvokePreStartInitMethodsCore(ICollection1 methods, Func1 setHostingEnvironmentCultures) +919

System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods) +169

System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +172

System.Web.Compilation.BuildManager.ExecutePreAppStart() +172

System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +854

[HttpException (0x80004005): The pre-application start initialization method Start on type System.Web.WebPages.Administration.PreApplicationStartCode threw an exception with the following error message: Attempt by security transparent method 'System.Web.WebPages.Administration.SiteAdmin.RegisterAdminModule()' to access security critical method 'System.Web.WebPages.ApplicationPart..ctor(System.Reflection.Assembly, System.String)' failed..]

System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +532

System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +111

System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +719

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.8.9319.0

Windows development | Internet Information Services
0 comments No comments

2 answers

Sort by: Oldest
  1. Danny Nguyen (WICLOUD CORPORATION) 8,725 Reputation points Microsoft External Staff Moderator
    2026-08-26T03:32:36.5366667+00:00

    Hi @Cacenco, Michael I'm looking into this issue and will get back to you soon. Thank you for your patience.

    Was this answer helpful?

    0 comments No comments

  2. Danny Nguyen (WICLOUD CORPORATION) 8,725 Reputation points Microsoft External Staff Moderator
    2026-08-26T03:59:44.6066667+00:00

    Hi @Cacenco, Michael ,

    Thanks for posting the stack trace. I think this is an assembly version mismatch rather than an IIS configuration problem.

    System.Web.WebPages.Administration.dll in your bin folder is likely a different version than the System.Web.WebPages.dll it calls into, so the .NET security transparency model blocks the call during pre-application start. This usually shows up after an MVC or Web Pages upgrade where the DLLs and the binding redirects in web.config fell out of sync.

    A few things to try:

    1. Check the section of your web.config and make sure the redirects for System.Web.Mvc, System.Web.WebPages, System.Web.WebPages.Razor, and WebMatrix.* point to the versions actually deployed in bin.
    2. In Visual Studio, run Update-Package from the Package Manager Console so all the Web Pages assemblies land on the same version, then republish.
    3. If you are not using the Web Pages site administration feature, try deleting System.Web.WebPages.Administration.dll from bin. It is not required at runtime and removing it has resolved this for others.

    If none of that helps, could you share:

    • The section from your web.config
    • The file versions of System.Web.WebPages.dll, System.Web.WebPages.Administration.dll, and System.Web.Mvc.dll in your bin folder
    • What changed right before this started, such as a framework upgrade, a new publish, or a server patch

    That will help confirm whether it is the mismatch or something else. You may also find this https://learn.microsoft.com/aspnet/mvc/overview/releases/how-to-upgrade-an-aspnet-mvc-4-and-web-api-project-to-aspnet-mvc-5-and-web-api-2 useful if this followed an MVC upgrade.

    Let me know how it goes. If you found my response helpful or informative, I would greatly appreciate it if you could follow this guidance or provide feedback.

    Thank you.

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.