Skip to content

RE: Special Directories in ASP.NET 2.0

Here are some interesting tidbits about ASP.NET 2.0….

ASP.NET 2.0 introduces a number of special directories for application resources. These directories live as subfolders in the application root, have special names, and offer various shortcuts and conveniences to web developers. One such folder is the App_Code folder. You can drop a .cs file into the App_Code folder, even while an application is running, and the runtime will automatically compile all the code inside the folder into an assembly.

The App_Code folder is one of those features experienced developers will shun in favor of class libraries. Other folders have definite advantages. For example, the App_Browsers folder will allow you to update browser definitions (browsercaps) for an application. In a shared hosting environment today, you’d have to clutter up web.config with new browsercaps. There are also special directories for skin files (App_Themes), resource files (App_GlobalResources, App_LocalResources, App_Resources), and web references (App_WebReferences). As always, the trusty Bin directory will also be around. Then there is App_Data. You can plop SQL Server data (.mdf) and log files (.ldf) into the directory, and have the engine attach dynamically by using AttachDBFileName in the connection string. App_Data will be a useful feature for people in shared hosting environments, where XCOPY and FTP deployment options are the only options available.

[Via K. Scott Allen]

I would like to see how the App_Data directory will play out in the real world. Most of the shared hosting plans have their own mechanism for handling client databases, it looks easy to add a database by just FTP’ing it in, but what about when you want to replace a database? You’ll still need to detach a database first.