Published: Monday, August 23, 1999
ASP Basics: What's Happening Back There?
With each new language it seems computers get easier and easier to program. When computers first came
into existence, programmers needed to know very cryptic and specific machine instructions to make those
ancient behemoths do anything. Before too long assembly languages arose, and then high-level
programming languages were introduced with the creation of Fortran. Today we have reusable components,
GUI/WYSIWYG designers, and easy to use scripting languages.
As computers become easier and easier to program, though, developers have to know less of what's
happening in the bowels of the compiler or interpreter. While this saves time, I think it is important
to have a firm grasp on what's going on behind the scenes. I think this is an important thing to know
for two reasons: one, it's cool; two, having a better understanding of what's really happening leads to
better written code, fewer bugs, and an improved self-esteem!
Before we begin discussing how ASP pages "work," let's talk about how static HTML pages "work." The
Internet is built on a client/server foundation. That means that there are two parts we must look at
when dissecting an Internet transaction: the client and the server. The client is the web browser, be
it Internet Explorer, Netscape, Lynx, Opera, or whatever. The server is the web server on which the
HTML page exists.
The entire process of retrieving a web page goes like this:
- You type in the URL into your browser, for example
http://www.yahoo.com/index.html
- Your browser finds the appropriate web server, and to that server says, "I need to look at the
file
/index.html, please."
- The web server locates the file
/index.html and sends it to the browser as HTML text.
- The browser collects this text and parses it, determining how to display those colorful animated
gifs and blinking text we've all come to love.
It's that simple. The transaction has just three simple steps: the client requests the document, the
web server sends the document, the client decides how to display it. With ASP, however, there are some
additional steps are taken on the server before the HTML text is sent back to the client. Let's
look at what happens with ASP:
- You type in the URL into your browser, for example
http://www.ASPisNeat.com/default.asp
- Your browser finds the appropriate web server, and to that server says, "I need to look at the
file
/default.asp, please."
- The web server locates the file
/default.asp and parses out the ASP code, turning all
of the ASP code into applicable HTML code. ASP code is code inbetween the ASP script delimiters
(<% ... %>) or in OBJECT tags with the RUNAT=Server
property set. Since all of the ASP is parsed into HTML, the client sees absolutely no
ASP code!
- The browser collects this HTML text and parses it, determining how to display those colorful animated
gifs and blinking text we've all come to love.
You'll note that there is again just three steps, although the second step is a bit more involved.
The whole process starts with the client requesting a file with a .ASP extension. The
web server notes the extension, and since it has a .ASP extension (as opposed to a
.txt, .htm or .html), the server parses the contents of the
requested file before sending it to the client. So when you view an ASP file through IE or Netscape,
your browser doesn't know that the .asp file is any different from a standard .html file!
Proceed to Part 2