Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
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.

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.


    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.


    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.

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.


    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.

Community Additions

© 2015 Microsoft