ASP 教程

经典 ASP 是什么、它在今天还有什么用,以及学习路线。

Beginner
Key PointsASP 是把 VBScript 嵌进 HTML、由 IIS 解释执行的服务端技术;今天的主要价值是维护存量系统。

ASP 是什么

ASP (Active Server Pages) is Microsoft's 1996 server-side scripting technology. An .asp file mixes HTML with VBScript; IIS runs the server-side script first, assembles HTML and sends that to the browser.

一个最小的 ASP 页

ASP
<%@ Language="VBScript" CodePage="65001" %>
<%
    Dim name
    name = Request.QueryString("name")
    If name = "" Then name = "World"
%>
<!DOCTYPE html>
<html>
<body>
  <h1>Hello, <%= Server.HTMLEncode(name) %></h1>
  <p>服务器时间:<%= Now() %></p>
</body>
</html>
Output
Hello, World
服务器时间:2026/11/3 14:25:09

<% %> holds server code and <%= %> prints an expression. Everything else goes to the browser untouched, so viewing source shows only HTML, never VBScript.

今天还要学吗

SituationShould you learn it
Maintaining a legacy site要 —— 很多企业内网仍在跑 ASP
Building something new不必 —— 用 ASP.NET Core 或 Node/PHP
Reading old code要 —— 至少能读懂 VBScript 与 ADO
Learning web basics可以,但 PHP 更通用

和 ASP.NET 不是一回事

ASP is an interpreted script; ASP.NET is a compiled .NET framework using C# or VB.NET on the .NET runtime. They share only a name and no code — renaming .asp to .aspx will not run.

ASP runs only on Windows with IIS (or a third-party emulation layer). Local development therefore requires Windows — one of the main reasons it faded.

学习路线

  1. 语法 —— Dim、If、For、Sub、Function
  2. 内置对象 —— Request、Response、Session、Application、Server
  3. 文件与数据 —— FileSystemObject、TextStream、ADO
  4. 组件 —— AdRotator、BrowserCap、Content Linking
  5. 与前端协作 —— AJAX 调 ASP 返回数据

Friends & Partners