Add and edit ASP.NET web pages

This walkthrough shows you how to create an empty website using a WebMatrix site template, add pages to the site, and edit them.

What you'll learn

  • How to create a website using a WebMatrix template.

  • How to add an HTML file to the site and edit it.

  • How to add a .CSHTML file to the site and edit it.

  • How to link the resulting pages to each other.

What you'll need

To run the steps in this procedure you must be running Windows XP SP3 or a later version of Windows. You'll also need to have WebMatrix installed. For information about how to install WebMatrix, see Microsoft Web Platform Installer.

Starting with the Empty Site Template

  1. Open WebMatrix.
  2. In the WebMatrix Quick Start page, click Site From Template.

    Image001
  3. In the Site from Template dialog box, select Empty Site.
  4. In the Site Name box, enter MySite and then click OK.

    Image002

    WebMatrix creates and opens the MySite website. On the left are workspaces, and on the right is the content area. At the top is the Home tab. The content area shows you a start page that contains options for working with your site.

    Image003

Editing a Web Page in the MySite Site

  1. In the content area, click Browse your files. (Alternatively, you can click the Files workspace selector in the left pane.)
  2. Click Create a new file.

     image004
  3. In the Choose a File Type dialog box, click HTML.
  4. In the Name box, enter Index.html.

     image004a
  5. Click OK.
  6. The page opens in the content pane.
    image005
     
  7. Replace the existing markup in the file with the following:
    <!DOCTYPE html>
    <html>
      <head>
        <title>Edit Page</title>
      </head>
      <body>
        <h1>Edit Page Example</h1>
        <p>Editing an existing page.</p>
        <a href="NewPage.cshtml">New Page</a>
      </body>
    </html>
       
    The <a> link points to a new page that you'll add in the next section.
  8. In the Quick Access Toolbar, click the Save icon to save the file.
  9. On the Home tab, click Run to view the page in the browser.

    Image006
  10. Close the browser.

Adding a New Page to the MySite Site

  1. In the Files workspace, in the left pane, right-click the root of the website (the MySite folder) and select New File.

    image006a

  2. In the Choose a File Type dialog box, click CSHTML. A CSHTML page can contain code to create dynamic behavior in the page.
  3. In the Name box, enter NewPage.cshtml.

    Image007
  4. Click OK.
  5. Replace the existing markup in the file with the following:
    <!DOCTYPE html>
    <html>
      <head>
        <title>Add Page</title>
      </head>
      <body>
        <h1>Add Page Example</h1>
        <p>This is a new page.</p>
        <a href="index.html">Back</a>
      </body>
    </html>
    The <a> link points to the page you created in the previous steps.
  6. Click Save in the Quick Access Toolbar.
  7. On the Home tab, click Run to view the page in the browser.

    image008
  8. Click Back, and you return to the first page that you created.

You can discuss this article using the adjacent Facebook talkback.

For technical questions please visit our discussion forums, where we have a vibrant community of developers like you, as well as Microsoft engineers who are ready to answer your questions!