Microsoft KB Archive/297943

= INFO: Getting Started with Active Server Pages =

Article ID: 297943

Article Last Modified on 7/4/2007

-

APPLIES TO


 * Microsoft Active Server Pages 4.0

-



This article was previously published under Q297943



SUMMARY
This article describes how to get started with Active Server Pages (ASP). This article is one of a series of articles that discuss an important &quot;Getting Started&quot; topic.



Audience
This article is intended for novice and intermediate customers who are familiar with computer programming. Although prior experience with a Web development language such as HTML is helpful, you do not have to have prior experience to complete the provided steps.

What is ASP?
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 &quot;live&quot; 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 frquently 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.

Step 1: Install ASP
Windows 2000

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. To install this option, follow these steps:
 * 1) In Control Panel, click Add/Remove Programs.
 * 2) Click Add/Remove Windows Components, and then select the Internet Information Services check box.
 * 3) In the Windows Component Wizard, click Next, and follow the on-screen instructions.

Windows NT 4.0 Server

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. To install ASP, select Internet Information Server from the setup dialog box in which you to select components to install. Also, install the latest Windows NT 4.0 Service Pack with the Option Pack.

To install the Windows NT 4.0 Option Pack and the latest Windows NT 4.0 Service Pack, visit the following Microsoft Web sites:

Windows NT 4.0 Option Pack

http://www.microsoft.com/ntserver/nts/downloads/recommended/NT4OptPk/

Windows NT 4.0 Service Pack

http://www.microsoft.com/ntserver/nts/downloads/

Windows 95, Windows 98, and Windows NT 4.0 Workstation

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. When the download wizard runs, select the appropriate operating system (for example, select Windows 95).

To download the Windows NT Option Pack, visit the following Microsoft Web site:

Windows NT Option Pack

http://www.microsoft.com/ntserver/nts/downloads/recommended/NT4OptPk

Windows Millennium Edition (Me)

ASP is not supported on Windows Millennium Edition.

Step 2: Configure a Web Application on the Web Server
After you install IIS or PWS, you must configure a Web application on the Web server. This article assumes that you are running IIS version 5.0 on Windows 2000. These instructions also work with IIS version 4.0 on Windows NT 4.0 Server, and the ASP code works on both IIS and PWS. For instructions on configuring a Web application for PWS, see the documentation that is included with PWS.NOTE: Microsoft Visual InterDev version 6.0 and Microsoft FrontPage 2000 can automatically perform application setup for you on the Web server. If you are using one of these programs to create Web sites, you can skip the following manual setup instructions and continue directly to step 3.
 * 1) On a Windows 2000-based computer, open the Internet Services Manager (ISM). To do this, on the Start menu, click Run, type inetmgr, and then click OK. The Internet Information Services (ISM) console opens.
 * 2) Expand the top-level node that contains your computer name. Right-click Default Web Site, click New, and then click Server Extensions Web.
 * 3) The New Subweb Wizard begins. Click Next to continue. In the Directory Name text box, type the name of the Windows folder to be created for your Web application. In the Title box, type an alias that points to the underlying physical Windows folder. The title is what users see as part of the URL path when they are browsing this Web application (for example, http://www.microsoft.com/ ). The title can be different from the underlying physical Windows folder name, but for this example, just type MyWeb for both the folder name and the title. Click Next, accept the default for Access Control, click Next again, and then click Finish.
 * 4) In the left pane of the ISM, select Default Web Site again, and press the F5 key to refresh the list of virtual folders. Note that your newly created application's virtual folder appears under the default site.
 * 5) Right-click the folder for your application, then click Properties. On the Directory tab, follow these steps:
 * 6) * Select Read access.
 * 7) * Make sure that Execute Permissions is set to Scripts only.
 * 8) * If the Create button is available, click it.
 * 9) Close the Properties dialog box. In the ISM, notice that the icon for your virtual folder does not appear as a yellow folder but as a green symbol in a gray box. This means that your application is set up and ready to host ASP pages, so you can close the ISM.

Step 3: Create Your First ASP Page
NOTE: 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.  Click Start, point to Programs, point to Accessories, and then click Notepad.  In Notepad, paste the following code for the basic page structure: <%@ Language=&quot;Vbscript&quot; %>  My First ASP Page

  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:  [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'.</li></ul>

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=&quot;Vbscript&quot; %> <meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=windows-1252&quot;> My First ASP Page

<%   '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 = &quot;Hello World! The current date and time are: &quot; & strTime & &quot;.<BR>&quot; &  _ &quot;The result of our calculation is: &quot; & strTotal

'Output the results to the browser Response.write strGreeting %>

</li></ol>

Step 4: Save the ASP Page to the Web Application
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, ), or for publicly accessible Internet sites, use your domain name (for example, www. .com). Finally, append the alias or title of your Web application's subfolder. The resulting URL resembles the following URL:

http:// /MyWeb

-or-

http://www. .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.

Step 5: 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:// /MyWeb/Default.asp

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

http://www. .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:// /MyWeb/

Additional Assistance with ASP
For more information, visit the ASP Newsgroup for peer-to-peer questions and answers. It is located under &quot;Internet Server Programming&quot;, which located under &quot;Web Development&quot; at the following Microsoft Developer Network (MSDN) Online Newsgroups Web site:

Online Newsgroups

http://msdn.microsoft.com/newsgroups/

For more information, visit the following Microsoft Web site:

Active Server Pages Support Center

http://support.microsoft.com/?scid=ph;zh-cn;555

For help with technical questions, visit the following Microsoft Web site to search the Microsoft Knowledge Base:

Knowledge Base Search

http://support.microsoft.com/search

To get help directly from Microsoft, visit the following Microsoft Web site and open a technical support incident:

http://support.microsoft.com/directory/question.asp?sd=gn&fr=0

For ASP tutorials, code samples, and references, visit the following Microsoft Web sites:

25+ ASP Tips to Improve Performance and Style

http://msdn.microsoft.com/workshop/server/asp/asptips.asp

Active Server Pages Guide

http://msdn.microsoft.com/library/psdk/iisref/aspguide.htm

Active Server Pages Tutorial

http://msdn.microsoft.com/library/default.asp?URL=/library/en-us/dnasp/html

All About Scripting

http://msdn.microsoft.com/workshop/author/script/allabout.asp

An ASP You Can Grasp: The ABCs of Active Server Pages

http://msdn.microsoft.com/workshop/server/asp/ASPover.asp

ASP Conventions

http://msdn.microsoft.com/workshop/server/asp/aspconv.asp

COM Objects in ASP

http://msdn.microsoft.com/workshop/server/asp/comtutorial.asp

For third-party ASP references and tutorials, visit the following Web sites:

4GuysFromRolla

http://www.4guysfromrolla.com/

15Seconds.com

http://www.15seconds.com

ASP101.com

http://www.asp101.com

ASPToday

http://www.asptoday.com/

ASPWire

http://www.aspwire.com/

LearnASP

http://www.learnasp.com

W3Schools.com

http://www.w3schools.com

Microsoft provides third-party contact information to help you find technical support. This contact information may change without notice. Microsoft does not guarantee the accuracy of this third-party contact information.

Microsoft ASP.NET
Microsoft ASP.NET is build on .NET technology and has many advanced features. For more information about ASP.NET, visit the following Microsoft Developer Network (MSDN) Web site:

http://msdn.microsoft.com/net/aspnet/default.asp

Keywords: kbinfo KB297943

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.