BeanSoftware Logo

ASP.NET Database Search Control

    Write For Us

Explained Error: The directory /App_Code is not allowed...

If you try to add /App_Code/ folder to your web application, in some scenarios is possible that site will return this error:

"The directory /App_Code is not allowed because the application is precompiled"

This error could be very confusing, but luckily solution is simple. Depending of your case, there are three possible scenarios:

You don't need /App_Code/ folder

App_Code folder, like /bin folder, have special function in ASP.NET application and you can't named ordinary folders with this name. So, if you named a folder "App_Code" but you didn't know that this name is reserved, you can simply rename it, and the error will disappear.

/bin folder contains classes in form of compiled assemblies, scoped to the current application. Similar to /bin folder, /App_Code folder also contains classes, but in form of source code as .cs or .vb files. When these files are uploaded to /App_Code folder, they are automatically compiled to assemblies and can be used like assemblies in /bin folder.

The error occurs if you published your web site as already compiled. In that case, you can't add new source code (in /App_Code folder). So what to do?

I need classes from /App_Code folder and I published compiled site

In this case, you don't need to have /App_Code folder on web server side. Just re-publish your web site and new classes will be available on web server as compiled assemblies in /bin folder.

I want to have /App_Code folder on web server

You probably published compiled web site before. Instead of publishing of compiled web site, you can use XCOPY and site will be compiled on web server. In this case, you need to delete special files created before, please create backup first ;)

- All files in /bin folder that starts with App_

- PrecompiledApp.config file in the site root

After this, you can create and use /App_Code file and hereafter use XCOPY to add new items to web site.

Happy Coding!

Related articles:

1. Errors And Exceptions In ASP.NET
2. Custom Error Pages In ASP.NET

FAQ toolbar: Submit FAQ  |  Tell A Friend  |  Add to favorites  |  Feedback

Copyright © 2002-2008 Bean Software. All rights reserved.