|Important||This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer|
How to: Add Files to ASP.NET Web Sites
You can add new and existing files to an ASP.NET Web site. Some file types can only exist in special ASP.NET subdirectories. For example, browser definition files (.browser) can only be created in the App_Browsers application subdirectory. If you attempt to create a browser definition file in the root of your application, Visual Web Developer will give you the option to put it in the App_Browsers subdirectory. For a list of file types, see Web Site File Types. For details about creating special ASP.NET folders, see the subsequent procedure.
Web sites in Visual Studio are directory based. When you open a Web site, Visual Studio treats all of the files in the folder that you open — whether the files are in the file system, in an Internet Information Services (IIS) application, or on an FTP site — as part of the same Web site. For more information, see How to: Create File System Web Sites.
To add a file to an ASP.NET Web site
In Solution Explorer, right-click the Web site project name, and then click Add New Item.
In the Add New Item dialog box, under Visual Studio installed templates, select the file type that you want to add.
If the Language list is enabled for the file type that you are adding, select the name of the programming language that you want to use for the file.
You can create files (pages) with different programming languages in the same Web site.
If you want the code for the page to be in a separate file, be sure the Place code in separate file check box is selected. if you want to keep the code and markup in the same file, clear this check box.
In the Name box, type a name for the file, and then click Add.
The new file is created and displayed in Visual Web Developer in the Source view window.
To create a special ASP.NET subdirectory
In Solution Explorer, right-click the Web site project name, and then click Add ASP.NET Folder.
In the list of available folders, click the name of the folder that you want to create.
For information about special ASP.NET folders, see ASP.NET Web Site Layout.
To add an existing Web page to a Web site project
In Solution Explorer, right-click the Web site project name, and then click Add Existing Item.
In the Add Existing Item dialog box, navigate to the directory that contains the Web page that you want to add, select the page, and then click Open.
The Web page is added to the Web site project.
When you add an existing file, the file is copied to your project not added by reference. Thus, if you change the file in your project, the original file is left unchanged.
To change the name of a Web page using Solution Explorer
In Solution Explorer, right-click the file name that you want to change and then click Rename.
Type the new file name that you want and then press ENTER.
If the code for the page is in a separate file, Visual Studio automatically renames the code file as well and changes the @ Page directive in the .aspx page to match the renamed code file.