Getting Started With ASP.Net Web Pages 2

Introduction

In the release of the new version of Visual Studio various useful and creative features are also released. Here in this article, I am describing one of them, ASP.NET Web Pages Version 2. The ASP.NET Web Pages with Razor syntax is a very lightweight framework for creating dynamic websites. You can also get the benefit of WebMatrix for creating web pages and websites.

In that context, you will learn here the ASP.NET Web Pages technology, WebMatrix and the creation of web pages and websites by WebMatrix. I assume that you are quite familiar with the technologies listed below:

  • HTML
  • CSS
  • Database

Prerequisites

  • Windows XP SP3, 7 or later, Windows Server 2003 SP2 or later
  • Connected to Internet
  • Administrator Authorization for Installation

Brief

The ASP.NET Web Pages is a framework for creating dynamic websites. When you create a web page by HTML, that page is the static web page. The ASP.NET Web Pages let you create a dynamic web page.

You can take the input and store the information into the server in the dynamic web pages. You can email the information, retrieve the data, map to the services and integrate the info and so on with the dynamic pages.

WebMatrix

It is a web tool to integrate the web page editor, a database utility and a web server for testing pages. It is free, easy to install and use.

So, let's get started with the following sections:

  • Installing WebMatrix
  • Working with WebMatrix
  • Launch Site

Installing WebMatrix

At first we install the WebMatrix to start. The Web Platform Installer by Microsoft is used to install everything. Proceed with the following procedure.

Step 1: It is free to download from the WebMatrix page as in the following:

WebMetrix Installation

Step 2: Start the setup and click to install the WebMatrix.

Install Microsoft WebMetrix 3

Step 3: By following the installation procedure you will reach the final step of installation.

Final Web Metrix Installation

Working with WebMatrix

When the installation completes, WebMatrix is launched automatically; if not then open it. For the first time, you can enter the credentials to sign into Microsoft and you'll get 10 free websites through Windows Azure. You can however do that later by choosing the "Not now" option. So, proceed with the following procedure.

Step 1: Click on the "Not now" option.

Microsoft Sign In

Step 2: In the next wizard, click on the New and select the Template Gallery option to create various types of websites.

Create New Template in Web Metrix

Step 3: Select the "Empty Site" and enter the website name, click on "Next".

Create New Empty Site in Web Metrix

Note: If you've signed in by your account then skip the website creation in Azure.

Step 4: It'll open the site

Site Structure in Web Metrix

Now you've created a website by WebMatrix and we'll create the web page sample from it.

Step 5: Click on "New" to create a new file.

Creating New File in Web Site

Step 6: There are various types of files you can create. Select "CSHTML file" and enter the name as as CricketerPage

Creating Cshtml File

Step 7: WebMatrix creates the default structure of the page in the editor. Modify the code with the highlighted code below:

@{
}
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8" />
        <title>Best Cricketer</title>
    </head>
    <body>
        <h1>Cricketers Page</h1>
        <p>You will see the Best Cricketers here.</p>
    </body>
</html>

Step 8: Save the file.

Launch Site

We've created a sample chstml page, let's check on it in a browser using the following procedure.

Step 1: Just right-click on the CricketerPage.cshtml and select "Launch in Browser".

Launch Site in Browser

WebMatrix publishes the page through IIS Express. The page opens in your default browser

Opening Site in Browser

In the browser, you can see the URL that is like http://localhost:1234/CricketerPage.cshtml, in other words that the local server uses to access the page. WebMatrix includes a web server program named IIS Express that runs when you launch a page.

Summary

This article has introduced you to the ASP.NET Web Pages 2 and WebMatrix so that you can create dynamic pages and websites and run it on the local server as IIS Express. In future articles, we'll do some programming on the Web Pages. Thanks for reading.


Similar Articles