lulupedia
kernowek 版本暂未收录,当前展示 English 内容。

Active Server Pages

5002 words·2026-09-24·English
0

Active Server Pages (ASP), later referred to as Classic ASP, is a server-side scripting environment developed by Microsoft that enables the creation of dynamic, interactive, and database-driven web pages.

History and Evolution

Active Server Pages was first introduced by Microsoft in December 1996 as a component of Internet Information Services (IIS) 3.0. It was designed to provide a robust alternative to Common Gateway Interface (CGI) scripts, which were the prevailing method for generating dynamic web content at the time. ASP evolved through three major versions: ASP 1.0 (IIS 3.0), ASP 2.0 (IIS 4.0), and ASP 3.0 (IIS 5.0), which introduced improvements such as the Server.Transfer method, the ASPError object, and enhanced performance. In 2002, Microsoft released the .NET Framework and introduced ASP.NET, a fundamentally different, compiled, and object-oriented successor. Following this release, the original technology was retroactively dubbed "Classic ASP" to distinguish it from the new framework.

Architecture and Execution Model

ASP operates on a server-side execution model tightly integrated with Microsoft's Internet Information Services (IIS). When a web browser requests a file with the .asp extension, IIS intercepts the request and passes the file to the ASP scripting engine (typically asp.dll). The engine reads the file sequentially, executing any server-side script blocks while passing standard HTML directly to the output stream. Once the entire page is processed, the resulting HTML is sent back to the client's browser. This architecture ensures that the underlying source code and database credentials remain hidden from the end-user, as only the generated markup is transmitted over the network.

Scripting Languages and Syntax

ASP is language-agnostic in design, relying on the Windows Active Scripting framework. However, VBScript was established as the default and most widely used scripting language for ASP development. Developers could also configure the environment to use JScript (Microsoft's implementation of ECMAScript) or third-party engines like PerlScript. The scripting language for a specific page or application could be declared using the @LANGUAGE directive.

Code blocks in ASP are enclosed within specific delimiters. The standard delimiter <% ... %> is used for executing control structures, variable assignments, and logic. To output the result of an expression directly to the HTML stream, the shorthand <%= ... %> delimiter is utilized.

Built-in Object Model

To facilitate web development, ASP provides a set of built-in objects that abstract common HTTP and state-management tasks:

  • Request: Captures data sent from the client to the server, including query string parameters, form submissions, cookies, and client certificates.
  • Response: Controls the output sent back to the client, allowing developers to write HTML, set HTTP headers, manipulate cookies, and redirect users.
  • Server: Provides utility methods for server-side operations, such as instantiating COM objects (Server.CreateObject), mapping virtual paths to physical file paths (Server.MapPath), and encoding or decoding strings for safe HTML or URL usage.
  • Session: Stores user-specific variables and objects that persist across multiple page requests during a single user's visit, relying on a session ID cookie.
  • Application: Stores variables and objects that are shared globally across all users and sessions within a specific web application.
  • ASPError: Introduced in ASP 3.0, this object provides detailed information about the last error that occurred during script execution, facilitating custom error-handling pages.

Component Object Model (COM) Integration

One of the most powerful features of Classic ASP is its seamless integration with the Windows Component Object Model (COM). Through the Server.CreateObject method, developers can instantiate and interact with custom or built-in ActiveX components. This extensibility allowed ASP to perform complex tasks beyond basic scripting. Commonly used COM components included ActiveX Data Objects (ADO) for relational database connectivity, Collaboration Data Objects (CDO) for sending SMTP emails, and the Scripting.FileSystemObject for reading and writing files on the server's local file system.

Security Considerations

Because Classic ASP was developed before modern web security paradigms were fully established, applications written in it are often susceptible to common web vulnerabilities if not coded rigorously. SQL injection is a prevalent risk when database queries are constructed using string concatenation with unvalidated user input. Cross-Site Scripting (XSS) can occur if user-supplied data is reflected in the HTML output without proper encoding using Server.HTMLEncode. Additionally, improper use of the FileSystemObject or Server.MapPath can lead to path traversal attacks. Mitigating these risks requires strict input validation, the use of parameterized queries via ADO, and rigorous output encoding.

Legacy and Modern Usage

Although ASP.NET has been the standard for Microsoft web development for over two decades, Classic ASP retains a legacy footprint. Microsoft has continued to include support for Classic ASP in modern versions of IIS, though it is typically disabled by default and must be explicitly enabled as an optional Windows feature. Many enterprise organizations continue to maintain legacy Classic ASP applications due to the high cost and complexity of rewriting them in modern frameworks. However, for new development, Microsoft and the broader developer community strongly recommend using ASP.NET Core, which offers superior performance, cross-platform capabilities, modern security features, and a robust, maintainable architecture.

Comments (0)

U

No comments yet. Be the first to comment!

You May Be Interested In

Related Articles