Creating a Directory Structure for an ASP.NET Application
Applies To: Windows Server 2003, Windows Server 2003 R2, Windows Server 2003 with SP1
How you organize the directories that your applications contain affects any virtual or relative paths that are included in the files that your application contains. In addition, if your application uses local compiled code, you must include a \Bin directory directly beneath your application root. ASP.NET automatically resolves any references to components stored there.
The procedures in this topic explain which directories to include in the root directory of your ASP.NET Web application. A short discussion of possible directory structures follows, and a sample directory structure with potential file names is included at the end of the topic.
Procedures
To prepare for this walkthrough
- Create a root directory for your application and mark it as an application, as described in Creating an ASP.NET Application Root Directory with IIS.
To create a directory structure for your ASP.NET Web application
At the command prompt or in Windows Explorer, open the root directory you created.
Create a new directory and name it Bin.
Create any other directories that your application requires. For example, you could create a directory to contain all the images that your application contains.
The \Bin directory is the default assembly cache for your Web application. Unless your Web application shares DLLs with another application, place all DLLs that your application uses in the \Bin directory to ensure that references to the objects contained in them resolve correctly. These assemblies can include business logic or compiled custom server controls. If your application shares assemblies with other applications, place the shared DLLs in the global assembly cache. For more information, see Deploying Shared Components to the Global Assembly Cache.
Note
These instructions do not apply to assemblies compiled by Visual Studio .NET when you create an ASP.NET Web application in that environment. For information about how to deploy Web applications developed using Visual Studio .NET, see Visual Studio Help.
If you want to modify the default configuration for your Web application, create a Web.config file, make the modifications you want, and save it in the root directory. For more information, see Overview of ASP.NET Configuration.
In addition, if you write any application-wide functions, including handlers for Application_Error events, place those in a Global.asax file and save the file in the application root directory. For more information, see the "ASP.NET Applications" topic in .NET Framework Help .
In the following sample directory structure, C:\myWebApp is the application root directory. For the application to function properly, the myWebApp directory must be an IIS virtual directory.
Note
This simple application includes the \Bin directory and an |Img directory, which stores the image associated with the application. Your directory structure might be more complex than this.
c:\myWebApp
Default.aspx
Menu.ascx
Service.asmx
Web.config
Global.asax
\Bin
myBizLogic.dll
\Img
myImage.gif