Microsoft initially developed Active Server Pages (ASP) to support a larger number of developers than just those using C++ to commence Web development. When IIS came out, it was indeed a feasible environment for developing Web sites on the Microsoft platform compared to other platforms. In fact, you can still see some sites today arranged as pure ISAPI DLL sites; just look in the query strings going between the browser and the server for clues (eBay for one).

For example, you might observe a file name such as ACMEISAPI.DLL embedded within the query string.

However, writing an entire site using ISAPI DLLs can be daunting. Writing ISAPI DLLs in C or C++ gives you total control over how your site will perform and makes the site work.

However, along with that control comes an equivalent amount of accountability because developing software using C or C++ presents several challenges.

So in conveying ASP, Microsoft provided a single ISAPI DLL named ASP.DLL. ASP Web developers write down their code into files labeled with the extension .asp (for example, some file .asp). ASP files repeatedly contain a mixture of static HTML and executable sections (usually written in a scripting language) that emit output at runtime.

For example, the code in Listing 1-1 illustrates an ASP program that spit outs the HelloWorld page, which contains both static HTML and text generated at runtime. (The file name is HelloWorld.asp in the book’s accompanying examples.)

LISTING 1-1 A Classic ASP File
<%@ Language="javascript" %>
<html>
<body>
<form>
<h3>Hello world!!! This is an ASP page.</h3>
<% Response.Write("This content was generated");%>
<% Response.Write("as part of an execution block");%>
</form>
</body>
</html>


The rules had shown in Listing 1-1 provides the following page. IIS observed port 80 for requests. When a request for the file Helloworld.asp came through, IIS saw the .asp file expansion and asked ASP.DLL to handle the request (that’s how the file mapping was set up). ASP.DLL merely rendered the static HTML as the string “Hello world!!! This is an ASP page.” Then when ASP.DLL come across the funny-looking execution tags (<% and %>), it effected those blocks by running them through a JavaScript parser (note the language tag in the first line of code).

Figure 1-2 shows how the page renders in Internet Explorer.




Listing 1-2 shows the SelectFeature.htm page rewritten as a classic ASP page. appearing at this easy ASP application presents some of the center issues in Web development and illustrates why Microsoft rewrote its Web server technology as ASP.NET. (The accompanying file name is SelectFeature.asp.)

LISTING 1-2 The SelectFeature.htm Page Rewritten as a Classic ASP Page
<%@ Language="javascript" %>
<html>
<body>
<form>
<h2>HelloWorld<h2>
<h3>What's your favorite .NET feature?</h3>
<select name='Feature'>
<option> Type-Safety</option>
<option> Garbage collection</option>
<option> Multiple syntaxes</option>
<option> Code Access Security</option>




FIGURE 1-2 The results of a request made to the ASP program from Listing 1-1

<option> Simpler threading</option>
<option> Versioning purgatory</option>
</select>
</br>
<input type=submit name="Submit" value="Submit"></input>
<p>
Hi, you selected <%=Request("Feature") %>
</p>
</form>
</body>
</html>


Much of the text in SelectFeature.asp looks much related to SelectFeature.htm, doesn’t it? The variations lie mainly in the first line (that now specifies a syntax for executable blocks) and the executable block marked by <% and %>. The rest of the static HTML renders a selection control within a form.

Executable block: The executable block examines the characteristic control (specified by the <select> tag) and prints out the value selected by the user.

Figure 1-3 shows how SelectFeature.asp renders in Internet Explorer.



The screen in Figure 1-3 may seem to be a bit odd because the drop-down list box shows “Type-Safety” while the rendered text shows “Simpler threading.” Without performing anything extra, the drop-down list box will always re-render with the first element as the selected element.