Introduction to Active Server Pages

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

Discussion

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" %]
[html]
  [head]
    [meta http-equiv="Content-Type" content="text/html; charset=windows-1252"]
    [title]My First ASP Page[/title]
  [/head]
  [body]
  [/body]
[/html]

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]
[/Script] 

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" %]
[html]
  [head]
    [meta http-equiv="Content-Type" content="text/html; charset=windows-1252"]
    [title]My First ASP Page[/title]
  [/head]
  [body]
  [%
    '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
    'variables.
    strGreeting = "Hello World! The current date and time are: " & _
                  strTime & _
                  ".[BR]" & "The result of our calculation is: " & _
                  strTotal
    'Output the results to the browser
    Response.write strGreeting
  %]
  [/body]
[/html] 

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:

C:/Inetpub/Wwwroot/MyWeb

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, www.MyCompany.com). Finally, append the alias or title of your Web application's subfolder. The resulting URL resembles the following URL:

http://MyServer/MyWeb

-or-

http://www.MyCompany.com/MyWeb 

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:

http://MyComputerName/MyWeb/Default.asp 
                      

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

http://www.MyCompany.com/MyWeb/Default.asp 
                      

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:

http://MyComputerName/MyWeb/ 

Active Server Pages, ASP 0113 (0x80004005)超过了脚本运行的最长时间

1、错误类型:Active Server Pages, ASP 0113 (0x80004005)超过了脚本运行的最长时间。可以为 Server.ScriptTimeOut 属性指定新值或更改 IIS...
  • hong401
  • hong401
  • 2009-05-16 14:41:00
  • 4750

Active Server Pages 错误 'ASP 0131' 错误

最近第一次使用WINDOWS 2003 SERVER很多操作和原来2000/XP不一样。下面把碰到的IIS6.0的问题说一下。Active Server Pages 错误 ASP 0131 错误不允许...
  • ening306
  • ening306
  • 2007-07-02 13:50:00
  • 3497

Active Server Pages 错误 'ASP 0240'

在WEB服务器上打开任何ASP网页出现如下错误: Active Server Pages 错误 ASP 0240 Script Engine 异常 /index.asp 一个 ScriptEngine...
  • judge9999
  • judge9999
  • 2006-12-11 11:04:00
  • 2484

Active Server Pages 错误 'ASP 0131' 不允许的父路径

出错了,我的windows 2003 刚安装好,迁移了之前在xp下的ASP文件。 之前在xp下没问题的在2003上就报Http:500 内部服务器出错的消息 ,我顶他的肺。 找了N久没有找到问题,后来...
  • e_zhiwen
  • e_zhiwen
  • 2010-08-15 08:49:00
  • 3415

Active Server Pages 错误 'ASP 0126'

注意相对引用时的路径!注意要收用的文件是在上一级目录,当前目录,还是下级子目录. 上级目录就用 "../文件名"; 当前目录就用 "文件名"; 下级子目录用 "子目录/文件名"; ...
  • com0do
  • com0do
  • 2007-12-04 12:19:00
  • 1164

Windows2003中不允许的父路径问题Active Server Pages 错误 'ASP 0131'

Active Server Pages 错误 ’ASP 0131’ 不允许的父路径 /Main/default.asp,行 2 包含文件 ’../public/ucode.asp’ 不能用 ’..’ ...
  • helloLife
  • helloLife
  • 2006-10-08 15:42:00
  • 2513

Appdev Active Server Pages Training.zipAppdev Active Server Pages Training.zip

  • 2010年03月07日 14:21
  • 4.5MB
  • 下载

Active Server Pages(ASP内置对象)

  • 2009年04月07日 11:28
  • 139KB
  • 下载

Sun Java System Active Server Pages 4.0

  • 2015年06月14日 11:56
  • 20.93MB
  • 下载

Active Server Pages 错误 'ASP 0201' 无效的默认脚本语言 为此应用程序指定的默认脚本语言无效。

Active Server Pages 错误 ASP 0201 无效的默认脚本语言 为此应用程序指定的默认脚本语言无效。 搞了半天才搞好,原来:问题出在MS OFFICE身上,而出问题的系统一般都是W...
  • topso
  • topso
  • 2006-10-24 16:26:00
  • 6449
收藏助手
不良信息举报
您举报文章:Introduction to Active Server Pages
举报原因:
原因补充:

(最多只允许输入30个字)