The directory '/website/App_Code/' is not allowed because the application is precompiled
Asked Answered
V

5

40

How can I resolve the below issue that I get when I am running my precompiled web app?

Server Error in '/CRM' Application.
    The directory '/CRM/App_Code/' is not allowed because the application is precompiled.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Web.HttpException: The directory '/CRM/App_Code/' is not allowed because the application is precompiled.

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Stack Trace:


    [HttpException (0x80004005): The directory '/CRM/App_Code/' is not allowed because the application is precompiled.]
       System.Web.Compilation.CodeDirectoryCompiler.GetCodeDirectoryAssembly(VirtualPath virtualDir, CodeDirectoryType dirType, String assemblyName, StringSet excludedSubdirectories, Boolean isDirectoryAllowed) +8777420
       System.Web.Compilation.BuildManager.CompileCodeDirectory(VirtualPath virtualDir, CodeDirectoryType dirType, String assemblyName, StringSet excludedSubdirectories) +125
       System.Web.Compilation.BuildManager.CompileCodeDirectories() +387
       System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled() +248

    [HttpException (0x80004005): The directory '/CRM/App_Code/' is not allowed because the application is precompiled.]
       System.Web.Compilation.BuildManager.ReportTopLevelCompilationException() +62
       System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled() +421
       System.Web.Compilation.BuildManager.CallAppInitializeMethod() +31
       System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +605

    [HttpException (0x80004005): The directory '/CRM/App_Code/' is not allowed because the application is precompiled.]
       System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +8946484
       System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +97
       System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +258


    Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1
Verniavernice answered 30/6, 2014 at 7:25 Comment(1)
possible duplicate of Precompilation related error from an ASP.NET website that is NOT precompliedBlocky
S
35

Depending on your case, there are three possible scenarios:

see this link http://www.beansoftware.com/ASP.NET-FAQ/Directory-App_Code-Not-Allowed.aspx

Basically, If you precompiled your app, there shoudn't be an App_Code folder. If you added it later, you should delete it.

OR

May be Somehow a precompiled.config file has made it to production. Deleting that file should resolve the App_Code directory error.

Segal answered 30/6, 2014 at 7:34 Comment(0)
S
20

Deleting the "precompiledApp.config" file should solve your problem.

Schlueter answered 13/4, 2016 at 7:34 Comment(0)
B
2

In my case I compiled with "ASPX files are updateable" option checked OFF. I guess the IIS my website was running on did not like that.

Once I recompiled with "ASPX files are updateable" option checked ON, the issue disappeared.

Bedesman answered 5/12, 2018 at 12:38 Comment(0)
B
1

In my case, I mistakenly, forced Publish a class, which caused this issue.

The Solution was to make an update on the offending class, then Publish again with the option "Delete unused files from the Destination Site". (Which is under the publish modal options)

Bernadinebernadotte answered 15/8, 2016 at 23:3 Comment(0)
G
0

App_Code is a special folder with a special function in the ASP.NET application. It is a reserved folder like app_browsers, app data, app start, bin, etc..

The App_Code folder works much like the Bin folder. The bin folder contains compiled code files. While, the App Code contains source code files, which are compiled at runtime. The resulting assembly is accessible to any other code in the Web application.

Solution(s): [To view the full demo: [Fix the directory app_cod is not allowed]1

  1. Ensure that no ordinary folder is named App_Code in your application. If required, add it as an ASP.Net folder.
  2. If, previously, the application was published precompiled, you can't add new source code to the App Code folder. Uncheck the "precompile during publishing" option on the publish page and republish.
  3. On the server, from the published site folder, delete the PrecompiledApp.config file, and republish your application.
  4. Make sure that in the advanced precompile options, "allow precompiled site to be updateable" is selected.
  5. Select the "Delete all existing files prior to publish" option and republish.
  6. Delete contents of obj folder and exclude it from the project then republish.
  7. Manually clear all the files from the published site folder on the server.

If the publishing process has been concluded successfully, but the landing page, on the browser, is still not loading properly. Ensure that, in Visual Studio, all the files are included in the project. Some files (scripts, css etc.) might be excluded after the first successful publishing and republish the whole project.

Gordie answered 12/12, 2023 at 9:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.