Tutorial : Learn ASP.NET 2.0 - A "From the Ground Up" Tutorial
The New ASP.NET Architecture
For developers, ASP.NET 2.0 is the technology platform that will take us to the next level of software. If you're coming from a background of "old" ASP or VB 6, get ready for a completely new world. Microsoft decided to bet the farm on .NET and COMPLETELY overhaul their architecture. It will be easier for you to learn if you simply don't assume that anything is the same anymore.
ASP.NET 2.0 assumes that both a "client" and a "server" are present. In this course, they will both be on the same computer: your PC. But they're both still there. After you develop your system, you can upload it to a real web hosting service and run it on the real web if you like.
One of the things that is difficult for new students to get their head around is the assumed sequence of operations in ASP.NET.
You have to get completely straight in your head is what is happening on which system. It can be very confusing, so we'll invest some serious time explaining this point.
The completely new architecture of ASP.NET 2.0 does have one very good result for older technologies. you can mix and match HTML and ASP.NET to get exactly the result you want. You can even include code based on the "old" ASP. The "server" makes a determination, based on file types, about which type of processing needs to be done. An .html (or .htm) file gets sent straight to the browser, but an ASP.NET file (one that ends in .aspx), gets ASP.NET processing at the server first.
In fact, you could simply rename any valid .html or .htm file as .aspx and it would run just fine on an ASP.NET server. The only thing that would happen is that the ASP.NET software on the server would check for any ASP.NET code and then pass the file to the regular server processing. To prove the point, and to introduce you to VWD and make sure your software is installed correctly, we're going to do just that.
The following code is a more or less "traditional" Hello World application written in straight HTML.
<html>
<head>
<title>
About VB Hello
</title>
</head>
<body>
<h1>Hello World from About Visual Basic</h1>
<p>This Hello World is straight HTML.</p>
</body>
</html>
We're going to create this as an .aspx page in VWD and run it using the builtin web server in VWD.
If you have downloaded and installed VWD, you should see a "Microsoft Visual Web Developer 2008 Express Edition" shortcut in "All Programs". Just click that to get started. Once the system is up and running, select File > New Web Site ... from the menu. Then select the ASP.NET Web Site template. Make sure Language is Visual Basic and select File System from the Location dropdown. You can change the name and the location on disk to anything that works for you. For this experiment, I recommend leaving it at the default values. VWD will build a "file-based" web site on your PC.
--------
Click
Here to display the illustration
Click the Back button on your browser to return
--------
VWD should open with the .aspx file for the Default page displayed. We're going to delete all of this for our experiment, but while it's on the screen, let's look at a few of the lines that are unique to ASP.NET.
--------
Click
Here to display the illustration
Click the Back button on your browser to return
--------
The first line in the page is:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
This called the Page directive and it tells the ASP.NET server what to do with the rest of the file. In all 'normal' ASP.NET pages, this will be present. Since this contains instructions to the server, it's not present in the HTML that the server eventually sends to the client.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
This is a standard HTML statement called the Doctype declaration and it's sent to the client. It's similar to the Page directive except that it instructs the browser, not the server, about what to do with the rest of the file.
In two places (the head statement and the form statement), you will see the attribute runat="server". This attribute tells the server to process the statement instead of sending it to the client. For this reason, statements that contain this attribute are called server side controls. The server converts the statement into standard HTML (which may do a lot of different things depending on what the control is) that is sent to the client.
But our experiment right now is to see if we can simply rename and run our very simple 'Hello World' HTML page as an aspx page. (Note ... this is not a recommended technique. It's just an experiment to help you understand what's really happening 'under the covers'.) Copy and replace all of the code in the default.aspx page with the HTML shown above and save the file. Note that no syntax errors are displayed in VWD.
Now you can actually run the page using the builtin ASP.NET development server by selecting View in Browser from the File menu. The result is shown below.
--------
Click
Here to display the illustration
Click the Back button on your browser to return
--------
This shows how standard HTML works with ASP.NET 2.0 as well as showing a simple example of VWD. But we can learn a little more about it by noticing that the actual page that is displayed is:
http://localhost:49208/LASP20_L1_1/Default.aspx
localhost is a default that has long been used in http to refer to the local machine. 49208 is called the port number and will nearly always be a different number for you if you try this at home. Ordinary web pages run on port 80 by default. The VWD development server avoids a conflict by running on a randomly selected port other than port 80.
We're not here to discover a more difficult way to code ordinary HTML, however, so on the next page we take the next step and briefly review "Classic" ASP. Partly because you might still see it in actual web pages and partly because to make sure you understand the interaction between client and server.

