ASP 简介

ASP 的运行机制、文件结构、与静态 HTML 的差别。

Beginner
Key PointsASP 文件由 IIS 的 asp.dll 处理:先执行脚本、再输出 HTML,所以能按请求生成不同内容。

运行机制

Text
浏览器  ──GET /hello.asp──▶  IIS
                              │
                              ├─ 静态文件(.html/.css/.jpg)→ 直接返回
                              └─ .asp → 交给 asp.dll 执行脚本
                                          ↓
                                     生成 HTML
                                          ↓
浏览器  ◀──────── HTML ────────────────┘

IIS decides by extension: .html is served as-is, .asp goes to the ASP engine. Rename an ASP page to .html and the <% %> blocks appear verbatim in the page.

ASP 文件里能放什么

ContentHandled by
HTML / CSS / JS原样发到浏览器
<% ... %>服务器执行
<%= ... %>服务器执行后插入结果
<!-- #include -->服务器在编译前合并

和静态页的差别

HTML
<!-- static.html:每个人看到的都一样 -->
<p>当前时间:不会变化</p>
ASP
<%-- dynamic.asp:每次请求都重新生成 --%>
<p>当前时间:<%= Now() %></p>
<p>你的 IP:<%= Request.ServerVariables("REMOTE_ADDR") %></p>
Output
当前时间:2026/11/3 14:25:09
你的 IP:203.0.113.42

The same URL can return different content on every request. That is the essence of a dynamic page: the server assembles content before responding.

常用内置对象

  • Request —— 读客户端传来的参数、头、Cookie
  • Response —— 写输出、设头、重定向
  • Session —— 每个用户一份的会话数据
  • Application —— 全站共享的数据
  • Server —— 创建对象、编码、映射路径
ASP has no real compilation step; the script is parsed per request. That makes development convenient but far slower than compiled frameworks, and IIS CPU saturates easily under load.

Friends & Partners