Implement Business Objects and Utility Classes
There are two folders specified in ASP.NET for storing code files or external assemblies. For the former, you can use the App_Code directory, for the latter, the Bin directory.
The App_Code subdirectory is used to store source code files (but not compiled code files). These files will be compiled at runtime (or during precompilation) into a single assembly. You can reference to these files (their namespaces, classes, structs, etc.) from anywhere in your application. But App_Code isn’t restricted to work with traditional source code files only. You can store XML schema (.xsd) files, for example to create a Data Access Layer. You can store .wsdl files for your Web Services respectively.
You can also use as many subfolders as you want, there is no difference in the calling syntax, because ASP.NET still compiles your folder into a single assembly. You don’t even need to set the language of the source codes stored in your App_Code folder. ASP.NET is able to identify what programming language you are using in your files, and use the compile needed. As long as you use one programming language in your App_Code folder, you don’t have to do anything.
If this isn’t the case, you need to put the different source codes in different folders inside your App_Code directory. Each subfolder can use only one programming language. When you are done with that, you need to configure your web.config file respectively, with the following syntax:
Of course you can use any directory name you like, as long as it’s an existing directory.
Note that when you are using the ASP.NET Web Application project type, you don’t need to use the App_Code folder, as your source code files will be compiled into a single assembly anyway.
Your Bin subdirectory can (and should) contain any compiled code files (for example .dlls) used by your application. Use this folder for dlls which aren’t ship with the .NET Framework. Just simply copy them into your Bin folder, and reference them with the following syntax, in your @Page directive (or in the web.config/configuration/system.web/pages/controls tag):
<% @Register Assembly=”AjaxControlToolkit” Namespace=”AjaxControlToolkit” TagPrefix=”cc1” %>
Assuming that the dll named AjaxControlToolkit.dll (specified in the Assembly attribute), and the default namespace is AjaxControlToolkit (in the Namespace attribute). Then you can reference the contents of the assembly as any part of ASP.NET.
When you reference assemblies that you have installed manually in your GAC (the keyword is manually, in which case they won’t be guaranteed to be installed on other devices as well), you need to include the referenced assembly in your Bin folder, and set your reference to that assembly contained in your Bin folder.