Export (0) Print
Expand All
15 out of 38 rated this helpful - Rate this topic

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

You can add new and existing Web pages to a Web project. For information about creating an ASP.NET Web project, see How to: Create File System Web Site Projects or How to: Create New Web Application Projects.

Web site projects in Visual Studio are directory based. When you open a Web site project, 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. For Web application projects, the project file (.csproj or .vbproj) determines whether a file is included in the project or not. The procedures in this topic will work for both project types.

For information about the difference between Web site projects and Web application projects, see Web Application Projects versus Web Site Projects.

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 Installed Templates, click the language that you want to work with, and then click Web Form.


    You can include pages with different programming languages in the same Web site project. For more information, see Walkthrough: Code Editing in Web Pages in Visual Studio.

  3. 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.

  4. 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 Visual Studio.

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 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.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

© 2014 Microsoft. All rights reserved.