ASP.NET WP – Getting Started


ASP.NET WP – Getting Started


”;


In this chapter, we will look at how to start a simple example using ASP.NET Web Pages. To begin with, we will create a new website and a simple web page.

How to Create a Blank Website?

To start with, launch Microsoft WebMatrix which we have installed in the previous chapter.

Web Matrix NewSite

We will create a blank site and then and add a page. To start with, click New and it will display the built-in templates.

Built in Templates

Templates are pre-built files and pages for different types of websites. To see all of the templates that are available by default, select the Template Gallery option.

Template Gallery Option

Select the Empty Site template and enter the Site Name. In this case, we have entered FirstWebPageDemo as the Site Name and then we have to click Next.

WebPage Demo

It will install the required packages. Once the installation is finished, WebMatrix creates and opens the site as shown in the following screenshot.

WebMatrix Creates

Create an ASP.NET Web Page

Now to understand and become familiar with WebMatrix and ASP.NET Web Pages, let’s create a simple web page by clicking New in the Home tab.

ASP.NET Web page

WebMatrix displays a list of file types as shown in the following screenshot.

WebMatrix Displays

Select CSHTML, and in the Name box, enter FirstPage.cshtml and click Ok.

Firstpage CSHTML

Now you can see that WebMatrix has created the page and opens it in the editor.

Let us first update the FirstPage.cshtml page as shown in the following program.

@{ }
<!DOCTYPE html>
<html lang = "en">
   
   <head>
      <meta charset = "utf-8" />
      <title>Welcome to ASP.NET Web Pages Tutorials</title>
   </head>
   
   <body>
      <h1>Hello World, ASP.NET Web Page</h1>
      <p>Hello World!</p>
   </body>

</html>

Now to test this web page, let’s select the arrow which is below the Run option on the Home tab and select Internet Explorer as shown in the following screenshot.

First Web Page

Now you will see the following empty web page.

Internet Explorer

Now let’s specify the following url − http://localhost:46023/firstpage in the browser and you will see the following output.

Hello World

Advertisements

”;

Leave a Reply

Your email address will not be published. Required fields are marked *