ASP.NET 2 introduces the concept of "page-based" assemblies. In
Visual Studio 2005 or Visual Web Developer Express 2005, you can
right-click on a page in the Solution Explorer and build the page by
selecting "Build Page". This action will only cause the page
selected, as well as any dependent code in App_Code, to be built.
To be more precise, this behaviour is also available for User Controls
(.ascx files).
One side-effect of this behaviour is that a website can now consist of
pages in multiple languages, Page1.aspx can be a VB page and Page2.aspx
can be a C# page. This is because the restriction on using mixed
languages is one language per assembly NOT one language per project.
But what about App_Code. By default all the code files build into
one assembly, so this would restrict us to one language. However,
by using sub-folders we can configure ASP.NET2 to build multiple
assemblies and therefore support multiple languages.
For example, consider the following structure for the App_Code folder:
App_Code
Folder1
Class1.vb
Folder2
Class2.cs
Folder3
Class3.js
As mentioned above, by default this would not build as there are three
languages and one assembly. However, by adding a
node to the node in
web.config, ASP.NET2 will now build 3 separate assemblies, one for each
folder, thus allowing our example above to work.
We cannot get carried away, however, we can only define a
codeSubDirectory node for direct children of App_Code. The
defined folders can have a deep structure, but we can only define
separate assemblies at the top-level. Thus, if we have the
following structure
App_Code
Folder1
Sub-Folder1
SubClass1.vb
Class1.vb
Folder2
Class2.cs
Folder3
Class3.js
Class1, and SubClass1 will be built into the same assembly.