To make sure we’re on the same page and that the code works, save this piece of
code in a file named Hello.aspx within the Learning virtual directory you created
in Chapter 1. Loading the file through http://localhost/Learning/Hello.aspx
should render the result shown in Figure 2.3.
Figure 2.3. Sample Page in action
As you can see, this ASP.NET page contains examples of all the above components
(except server-side includes) that make up an ASP.NET page. You won’t often
use every single element in a given page, but it’s important that you are familiar
with these elements, their purposes, and how and when it’s appropriate to use
The directives section is one of the most important parts of an ASP.NET page.
Directives control how a page is compiled, specify how a page is cached by web
browsers, aid debugging (error-fixing), and allow you to import classes to use
within your page’s code. Each directive starts with <%@. This is followed by the
directive name, plus any attributes and their corresponding values. The directive
then ends with %>.
There are many directives that you can use within your pages, and we’ll discuss
them in greater detail later, but, for now, know that the Import and Page directives
are the most useful for ASP.NET development. Looking at the sample ASP.NET
page in Figure 2.2, we can see that a Page directive was used at the top of the
page like so:
Visual Basic File: Hello.aspx (excerpt)
<%@ Page Language="VB" %>
Chapter 2: ASP.NET Basics