Syntax Basics

Special ASP blocks, and some rudimentary SSI support.

Details

Active Server Pages are standard HTML files with embedded script.

Two forms of the Server Side Include (SSI) directives are supported, and are processed before any ASP blocks:

These directives can be used anywhere a comment would be legal in the HTML. Conventionally, included files are given the .inc filename extension.

Warning

When using Python as an ASP scripting language, whitespace is very significant.

<% Response.Write(Application('started')) %> <!-- ERROR -->
<%Response.Write(Application('started'))%> <!-- OK -->

ASP Block Types

Server Directive Block

<%@ server directives %>Sets various ASP options (Server Directives). This block can only occur at the top of the ASP file, and only once.

Tip

To ensure that your pages will still work, unaltered, after moving to a new hosting provider (especially one unwilling or unable to change the IIS settings), or after a reinstall/upgrade of the server software (which could replace all of your custom IIS settings with the defaults), include a Language directive for any non-VBScript page, and an EnableSessionState directive whenever the Session object is used (session support can be very resource-intensive, and should be disabled unless needed).

Write Blocks

<%= expression %>Converted to Response.Write(expression). This block cannot contain line breaks.

Note

Adjacent write blocks will 'eat' any whitespace between them, so <%= firstname %> <%= lastname %> will result in BrianLalonde being sent to the browser. To prevent this, use the space (or nonbreaking space) character entity <%= firstname %> &#32; <%= lastname %>, or include the space character in a single write block <%= firstname+" "+lastname %>.

Procedural Blocks

<% procedural script %>Executes the procedural script, but doesn't directly insert anything into the resulting HTML. Translates literally into Response.WriteBlock(procedural script).