Partager via


How to: Add ASP.NET Web Pages to a Web Site

You can add new and existing Web pages to a Web site. For information about creating an ASP.NET Web site, see How to: Create File System Web Sites.

Web sites in Visual Studio are directory based. When you open a Web site, Visual Studio treats all of the files in the folder 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.

To add a new ASP.NET Web page to a Web site

  1. In Solution Explorer, right-click the project name, and then click Add New Item.

  2. In the Add New Item dialog box, under Visual Studio installed templates, click Web Form.

  3. In the Language list, select the programming language that you want to use for the new Web page.

    Note

    You can create pages with different programming languages in the same Web site.

  4. If you want the code for the page to be in a separate file, be sure that 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.

  5. In the Name box, type a name for the new Web page, and then click Add.

    The new ASP.NET Web page is created and displayed in the Visual Web Developer.

To add an existing ASP.NET Web page to a Web site project

  1. In Solution Explorer, right-click the project name, and then click Add Existing Item.

  2. In the Add Existing Item dialog box, navigate to the directory containing the Web page that you want to add, select the page, and then click Open.

    The ASP.NET Web page is added to the Web site project.

    Note

    When you add an existing file to a Web site, 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.

Changing the Name of ASP.NET Web Pages

After creating a new ASP.NET Web page or adding an existing page to a Web site project, you might want to change the name of the page file. You can easily rename pages in Solution Explorer.

To change the name of an ASP.NET Web page using Solution Explorer

  1. In Solution Explorer, right-click the file that you want to change and then click Rename.

  2. Type the new file name that you want and then press ENTER.

    Note

    If the code for the page is in a separate file, Visual Studio renames the code file as well and changes the @ Page directive in the .aspx page to match the renamed code file.

See Also

Concepts

Web Pages and Projects