The App_Code Directory

In ASP.NET 2.0, there are seven reserved directories where each directory has its own role. In this blog post, I will introduce the App_Code directory.

This directory is not automatically created when you create a new project, however the developer has to do it manually or it will be created if any feature requests it. It is used to store source code (Classes) from the same language, these classes are compiled at runtime to be used by the pages. Because HTTP Requests are blocked by the ISAPI filters from browsing this reserved directory, do not add any file except source codes; if you try to add an image and you use this image inside the webform, it will not be displayed at runtime.

Like I already mentioned, you can't add for example VB classes and C# classes under this directory, you have to add only classes using the same language because remember at runtime these classes are compiled into a single assembly. However, if you have VB Classes and C# Classes and u want to add them to this directory consider doing the below.

 

For example, under this folder create two new folders:

1) CSharp

2) VB

 

And now in the web.config add the below configurations

<configuration>

<system.web>

<compilation>

<codeSubDirectories>

<add directoryName="CSharp"/>

<add directoryName="VB"/>

</codeSubDirectories>

</compilation>

</system.web>

</configuration>

 

 

 

In this way, the compiler will create 1 single assembly for each directory.

 

Hope this Helps,

Comments

No Comments

The leading UI suite for ASP.NET - Telerik radControls
Outstanding performance. Full ASP.NET AJAX support. Nearly codeless development.