Introduction to Active Server Pages

原创 2004年08月26日 14:55:00


ASP is a set of software components that run on a Web server and allow Web developers to build dynamic Web pages. The advantage of ASP over static HTML Web pages is that an ASP page is like a computer program that runs on a Web server and can calculate results, process user input, read from or write to databases and files, and insert "live" updated content every time a user browses the page.

Related Technologies

ASP runs with a Web server on the Microsoft Windows platform. The Web server that is used is Internet Information Server (IIS). It is also possible to run ASP with a limited feature set on Microsoft Personal Web Server (PWS), which runs on Microsoft Windows 95, Microsoft Windows 98, and Microsoft Windows NT Workstation. ASP can also run on Unix operating systems by using special extensions that are created by software vendors.

Because ASP is frequently used to create business applications on the Web, it is regularly used with databases such as Microsoft Access, Microsoft SQL Server, or databases from other vendors. When used in conjunction with a database, ASP pages can even run transactional applications, such as those used by banks, by using the features of COM+ or Microsoft Transaction Server (MTS). A number of tools can be used to create ASP pages, ranging from simple text editors such as Notepad, popular Web site creation tools by Microsoft and other vendors, or a full-featured programming tool such as Microsoft Visual InterDev.

Running ASP

ASP version 3.0 is included with all versions of the Microsoft Windows 2000 operating system. ASP is installed automatically when you install the Internet Information Services option with Windows 2000. The older version of ASP, version 2.0, runs on Microsoft Windows NT 4.0 Server, which requires you to install the Windows NT 4.0 Option Pack. ASP version 2.0 also runs on Windows 95, Windows 98, and Windows NT 4.0 Workstation by installing Personal Web Server (PWS). PWS is included with the Windows NT Option Pack. However, ASP is not supported on Windows Millennium Edition.

Please Note: due to  DotNetNuke Text Editor problems with the less than and greater than characters, these have been replaced in this article with "[]" brackets.  If you copy and paste the markup in this article, you'll need to replace the "[]" brackets with the corresponding greater than and less than characters.

Creating Your First ASP Page

For this example, do not use Visual InterDev or FrontPage to create an ASP page. Although both applications can create ASP pages easily, it is better for learning purposes to hand-code the ASP page in a simple text editor such as Notepad.

In Notepad, paste the following code for the basic page structure:

[%@ Language="Vbscript" %]
    [meta http-equiv="Content-Type" content="text/html; charset=windows-1252"]
    [title]My First ASP Page[/title]

Type some ASP identifier tags and ASP code in the page. Note that for ASP code to run, it must be identified by one of the following sets of tags. The Web server uses these tags to identify the code that must be processed on the server before it returns the page to a browser. ASP identifier tag 1:

[% [Your ASP code goes here] %]

In this approach, you create an opening tag with the less than ([) and percent (%) symbols, a closing tag with the percent (%) and greater than (]) symbols, and you write your ASP code between the opening and closing tags. ASP identifier tag 2:

[Script runat="Server" ]
[Your ASP code goes here]

In this approach, the script tags are the same as the HTML script tags, except that the opening script tag has an attribute called runat='Server'. As an example, put a pair of ASP tags between the body tags in your ASP page. Between the ASP tags, input the following VBScript code sample so that the completed version of your ASP page resembles the following:

[%@ Language="Vbscript" %]
    [meta http-equiv="Content-Type" content="text/html; charset=windows-1252"]
    [title]My First ASP Page[/title]
    'Use an apostrophe to delimit code comment lines like this one.
    'Declare variables.
    Dim strGreeting, strTime, strTotal
    'Process and calculate.
    strTotal = 10 * 21
    strTime = Now()
    'Create a string that inserts the value of the two earlier
    strGreeting = "Hello World! The current date and time are: " & _
                  strTime & _
                  ".[BR]" & "The result of our calculation is: " & _
    'Output the results to the browser
    Response.write strGreeting

Save the ASP Page to the Web Server

Now save your ASP page to the Windows folder that is created for your Web application in step 1. When you used the Server Extensions Web Wizard in step 1, you typed a folder name for the physical Windows folder that contains your Web application's content, and then the wizard created the folder for you. By default, the wizard creates the new folder and subweb in the root site for IIS. Because you used the name MyWeb for your folder and your title alias, the typical path to it on your system resembles the following:


When the MyWeb application is running under IIS, and you use a Web browser to view the application, the URL path for the application starts with the Web protocol (http://). Next, if this is a local Web that is only on your computer or on your company intranet, use your Windows computer name (for example, MyServer), or for publicly accessible Internet sites, use your domain name (for example, Finally, append the alias or title of your Web application's subfolder. The resulting URL resembles the following URL:



To save the ASP page that you created in the previous step and put it in your Web application, follow these steps:

  1. In Notepad, on the File menu, click Save.
  2. In the Save As dialog box, use the Save In drop-down list box to locate your application's physical folder (for example, C:/Inetpub/Wwwroot/MyWeb).
  3. In the Save as type drop-down list box, select All Files.
  4. In the File Name text box, delete any default file extensions that you see, and then type your file name with the ASP extension (for example, Default.asp).
  5. Click Save.

Use the Web Server to View the Page

Open a Web browser, such as Microsoft Internet Explorer. In the address line, type the URL to your new ASP page. For example, if your server is running locally (that is, it is not serving pages on the Internet), the URL resembles the following:


Or, if your server is serving pages on the Internet, the URL resembles the following: 

Note that new Web applications in IIS are automatically set to use either Default or Index as a default file in the virtual folder for your Web application. In other words, if you use Default.asp as the name for your home page or the first page in your application, you do not have to use the file name in the URL. You can just locate the virtual folder that contains the Default.asp page, as follows:



Nutch的抓取流程。 N.B. 本文最重要的部分在第三节对比部分!
  • moqihao
  • moqihao
  • 2015年08月22日 17:10
  • 2416

Github Pages 静态网页建站

创建仓库 略。详见GitHub使用教程。 仓库属性设置 找Github Pages项。点击自动生成,按照提示操作,就会得到该项目的gh-pages 分支。 发布网站成功,地址为 http://chu...
  • chuchus
  • chuchus
  • 2014年08月31日 22:24
  • 2473


TORQUE安装笔记: Torque Resource Manager是一套OpenSource的软体,主要是用来控管丛集式电脑的工作排程,虽然是免费软体但功能还算蛮完整的,可以设定不同的工作类...
  • tengh
  • tengh
  • 2013年09月25日 09:19
  • 2128

sap sybase16备份及还原测试

开始备份数据库 BWDEV BWD/script% isql64 -Usapsa -Pxxxxx -SBWD -X  1> dump database BWD using config = 'BWDD...
  • xiegh2014
  • xiegh2014
  • 2016年04月06日 16:13
  • 638

指尖上的教程 for Pages

- 用手指来互动学习Pages  - 单击、双击、长按、拖动及各种快捷键,就像您在真正的Pages上学习使用一样  - 比观看视频、阅读书籍更加有趣、更加有效 - 哪里不会点哪里!妈妈再也不用担...
  • fzhlee
  • fzhlee
  • 2014年10月27日 11:00
  • 5026

小论文之旅(2)——introduction与related work

今天总结一下自己看的文献内容和查看的一些建议。 首先,在不确定你的文章的main idea的时候,不要着急写introduction,可以先写body部分内容,之后再写introduction部分...
  • u013408431
  • u013408431
  • 2016年08月27日 20:22
  • 3021

【读书笔记】《推荐系统(recommender systems An introduction)》第一章 引言

很久没上来写blog,前两个月赶上校招季节,都忙校招去了。 这本书我早就买来了,不过我从前看过项亮的《推荐系统实践》,看这本书的目录结构和项亮那本差不多,就一直放着没看。最近在做一个推荐系统...
  • xceman1997
  • xceman1997
  • 2014年12月02日 22:57
  • 1345

【读书笔记】《推荐系统(recommender systems An introduction)》第三章 基于内容的推荐

基于内容的推荐的基本推荐思路是:用户喜欢幻想小说,这本书是幻想小说,则用户有可能喜欢这本小说 两方面要求:(1)知道用户的喜好;(2)知道物品的属性 基于内容的推荐相比协同过滤方法(个人观...
  • xceman1997
  • xceman1997
  • 2014年12月07日 21:51
  • 1119

轻松搞定GitHub Pages

GitHub支持创建个人或组织以及项目这两种类型的网站。 本文章将向大家分享如何为项目、组织或个人创建一个GitHub Pages。为项目创建GitHub Pages你可以为你的项目创建一个GitH...
  • fengyuzhengfan
  • fengyuzhengfan
  • 2016年07月30日 00:37
  • 1196

[机器学习入门] 李弘毅机器学习笔记-7 (Brief Introduction of Deep Learning;深度学习简介)

[机器学习入门] 李弘毅机器学习笔记-7 (Brief Introduction of Deep Learning;深度学习简介) PDF VIDEOUps and downs of Deep...
  • soulmeetliang
  • soulmeetliang
  • 2017年06月05日 19:32
  • 1734
您举报文章:Introduction to Active Server Pages