Partilhar via


ASP.NET Web Project Folder Structure

You can keep your Web project's files in any folder structure that is convenient for your application. To make it easier to work with your application, ASP.NET reserves certain file and folder names that you can use for specific types of content.

Default Pages

You can establish default pages for your application, which can make it simpler for users to navigate to your site. The default page is the page that is served when users navigate to your site without specifying a particular page. For example, you can create a page named Default.aspx and keep it in your site's root folder. When users navigate to your site without specifying a particular page (for example, https://www.contoso.com/) you can configure your application so that the Default.aspx page is requested automatically. You can use a default page as the home page for your site, or you can write code in the page to redirect users to other pages.

Note

When you run a Web project in Visual Studio, the page that automatically runs when you press CTRL-F5 is determined by project settings. But when you run the site under Internet Information Services (IIS), default pages are established as properties of your Web site. It is also possible to specify a default page by using ASP.NET routing. For more information, see Setting Default Values for URL Parameters.

Application Folders

ASP.NET recognizes certain folder names that you can use for specific types of content. The following table lists the reserved folder names and the type of files that the folders typically contain.

Note

The content of application folders, except for the App_Themes folder, is not served in response to Web requests, but it can be accessed from application code.

Folder

Description

App_Browsers

Contains browser definitions (.browser files) that ASP.NET uses to identify individual browsers and determine their capabilities. For more information, see Browser Definition File Schema (browsers Element) and How to: Detect Browser Types and Browser Capabilities in ASP.NET Web Forms.

App_Code

Contains source code for shared classes and business objects (for example, ..cs, and .vb files) that you want to compile as part of your application. In a dynamically compiled Web site project, ASP.NET compiles the code in the App_Code folder on the initial request to your application. Items in this folder are then recompiled when any changes are detected.

Note

You can add any type of class file to the App_Code folder in order to create strongly typed objects that represent those classes. For example, if you put Web service files (.wsdl and .xsd files) in the App_Code folder, ASP.NET creates strongly typed proxies for those classes.

Code in the App_Code folder is referenced automatically in your application. The App_Code folder can contain subdirectories of files, which can include class files that in different programming languages. For more information, see Shared Code Folders in ASP.NET Web Site Projects and codeSubDirectories Element for compilation (ASP.NET Settings Schema).

App_Data

Contains application data files including .mdf database files, XML files, and other data store files. The App_Data folder is used by ASP.NET to store an application's local database, such as the database for maintaining membership and role information. For more information, see Introduction to Membership and Understanding Role Management.

App_GlobalResources

Contains resources (.resx and .resources files) that are compiled into assemblies with global scope. Resources in the App_GlobalResources folder are strongly typed and can be accessed programmatically. For more information, see ASP.NET Web Page Resources Overview.

App_LocalResources

Contains resources (.resx and .resources files) that are associated with a specific page, user control, or master page in an application For more information, see ASP.NET Web Page Resources Overview.

App_Themes

Contains a collection of files (.skin and .css files, as well as image files and generic resources) that define the appearance of ASP.NET Web pages and controls. For more information, see ASP.NET Themes and Skins.

App_WebReferences

Contains reference contract files (.wsdl files), schemas (.xsd files), and discovery document files (.disco and .discomap files) that let you create a Web reference for use in an application. For more information about generating code for Web services, see Web Services Description Language Tool (Wsdl.exe).

Bin

Contains compiled assemblies (.dll files) for controls, components, or other code that you want to reference in your application. Any classes represented by code in the Bin folder are automatically referenced in your application. For more information, see Shared Code Folders in ASP.NET Web Site Projects.

Managing Subfolders

Configuration settings for your site are managed in a Web.config file that is located in the site's root folder. If you have files in subfolders, you can maintain separate configuration settings for those files by creating a Web.config file in that folder.

Note

You cannot set or override configuration settings at the subfolder level if they apply to the site as a whole.

For more information, see ASP.NET Web Site Administration.

Restricting Access to Site Content

As part of the site's configuration, you can configure settings that restrict access to individual files or to subfolders. You can restrict content by individual users or by roles (groups). For details, see Managing Authorization Using Roles.

See Also

Tasks

How to: Create Web.config Files

Concepts

Shared Code Folders in ASP.NET Web Site Projects

ASP.NET Web Project Paths

ASP.NET Web Page Resources Overview

Other Resources

ASP.NET Web Projects

Web Application Projects versus Web Site Projects in Visual Studio

ASP.NET Themes and Skins