ASP 教程
经典 ASP 是什么、它在今天还有什么用,以及学习路线。
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 页
<%@ 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>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.
今天还要学吗
| Situation | Should 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.
学习路线
- 语法 ——
Dim、If、For、Sub、Function - 内置对象 ——
Request、Response、Session、Application、Server - 文件与数据 ——
FileSystemObject、TextStream、ADO - 组件 ——
AdRotator、BrowserCap、Content Linking - 与前端协作 —— AJAX 调 ASP 返回数据
ASP 是什么
ASP(Active Server Pages)是微软 1996 年推出的服务端脚本技术。.asp 文件里可以混写 HTML 和 VBScript,IIS 收到请求后先执行服务端脚本,把结果拼成 HTML 再发给浏览器。
一个最小的 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>Hello, World
服务器时间:2026/11/3 14:25:09<% %> 里是服务端代码,<%= %> 输出一个表达式的值。除这两处之外的内容原样发给浏览器——所以浏览器查看源码只能看到 HTML,看不到 VBScript。
今天还要学吗
| 场景 | 是否要学 |
|---|---|
| 维护老站点 | 要 —— 很多企业内网仍在跑 ASP |
| 做新项目 | 不必 —— 用 ASP.NET Core 或 Node/PHP |
| 看懂旧代码 | 要 —— 至少能读懂 VBScript 与 ADO |
| 学 Web 基础 | 可以,但 PHP 更通用 |
和 ASP.NET 不是一回事
ASP 是解释执行的脚本;ASP.NET 是编译执行的 .NET 框架,用 C# 或 VB.NET 写,跑在 .NET 运行时上。两者只有名字像,代码完全不兼容——把 .asp 文件改成 .aspx 是跑不起来的。
学习路线
- 语法 ——
Dim、If、For、Sub、Function - 内置对象 ——
Request、Response、Session、Application、Server - 文件与数据 ——
FileSystemObject、TextStream、ADO - 组件 ——
AdRotator、BrowserCap、Content Linking - 与前端协作 —— AJAX 调 ASP 返回数据