[This is preliminary documentation and subject to change]

# Using ASP to Manage Web Site Content

After learning HTML and creating a Web page, you are probably ready to begin designing a Web site. However, before doing so, you should consider the following issues:

- How will you maintain a consistent appearance across your entire site?
- How will you update content that appears on every page, such as copyright information or logo images?
- How will you incorporate Web content from multiple authors?

Even if your site is not large, these and other Web management issues can pose daunting and time-consuming challenges. Fortunately, your Web server includes Microsoft Active Server Pages (ASP), a server-side scripting environment that you can use to automate and centralize many of your Web site management tasks.

## Discover Scripting

A script is a series of instructions and commands that you can use to programmatically alter the content of your Web pages. If you have ever visited an online store that enabled you to search for items and check product availability, you have undoubtedly encountered some type of script. Equipped with a good understanding of scripting you can further realize the potential of Web based publishing.

To begin, there are two kinds of scripting: client-side and server-side.

Client-side scripts run on the Web browser and are embedded in a Web page between HTML <SCRIPT> and </SCRIPT> tags. If you view the HTML source for a highly dynamic Web page, most likely you will discover a client-side script.

Server-side scripts run exclusively on the Web server and are most often used to modify Web pages before they are delivered to the browser. Server-side scripts can instruct the Web server to perform an action such as processing user input or logging how often a user visits your Web site. You can think of server-side scripts as affecting how the Web server "assembles" a Web page before it's sent to the browser. Useful for processing data and automatically updating Web pages, server-side scripts can greatly facilitate your management of Web content.

## ASP: A Brief Overview

Just as you might write a custom macro to automate repetitive spreadsheet or word processing tasks, you create a server-side script to automatically perform difficult or repetitious Web management tasks. Imagine that you need to update a Web site consisting of several dozen pages containing identical formatting information (bylines, company logos, copyright information, and so on). Normally, such work is time-consuming and requires updating (and testing) each page by hand. Alternatively, you can use ASP to automate such work.

ASP is a powerful, server-side scripting environment that you can use to write scripts with only a standard text editor, such as Notepad. For example, using ASP you could create a central file that contains information common to all of the pages of a Web site. While designing the Web site, you could add a one-line script command to each page which inserts the contents of the central file. Whenever you need to update your site's navigation menu, for example, you need only update the central file; changes would automatically appear the next time a user reloads and views the Web content.

ASP uses delimiters to differentiate script commands from regular text and HTML. Specifically, <% and %> delimiters enclose script commands that are to be executed by the server, as opposed to < and > delimiters used by HTML to denote tags that are to be parsed by a Web browser.

The following example illustrates how ASP works:

    <%
      author = "Kim Yoshida"
      department= "Quality Assurance"
    %>

    This page was updated <B>today</B>, by <%= author %> from
    the <%= department %> Department.

When viewed in a Web browser, a page containing this script appears as:

    This page was updated today, by Kim Yoshida from the Quality
    Assurance Department.

However, a user viewing the source for this page would see only the following text and HTML:

    This page was updated <B>today</B>, by Kim Yoshida from the Quality
    Assurance Department.

The script runs on the server (that is, commands within the <% and %> delimiters are executed on the server) and returns only HTML to a user's browser.

At a minimum, all ASP files must have an .asp extension and contain script commands written in a scripting language such as Microsoft Visual Basic® Scripting Edition (VBScript) or Microsoft JScript. If you are new to scripting and need to learn the fundamentals, your local bookseller or the Windows Script Technologies, are good places to start.

After you familiarize yourself with a scripting language, see Getting Started with ASP to learn the fundamentals of ASP server-side scripting. This section also contains a hands-on, instructional tutorial. For more information, see ASP Tutorial.

## ASP Solutions

The following is a list a Web management tasks and suggested ASP solutions:

Web Task | ASP Solution
--- | ---
Update Web page formatting | Use the ASP server-side #include directive to insert information into each page from one central file. For example, when designing your site, insert the following statement in your Web page template:
    <!- - #include file="Logo.txt"  - ->
After your site has been deployed and you need to to update your logo image, you only need to update the Logo.txt file containing image information. For more information, see Including Files.
Alert users about relocated Web content | Rather than alert users, redirect them. Use the ASP Redirect method to automatically redirect or route a browser to another Web page or Web site. For example, insert the following statement at the top of a Web page to redirect users to another page:
    <% Response.Redirect(URL of new Web page) %>
For more information, see Sending Content to the Browser.
Support disparate versions and brands of Web browsers | Use the ASP Browser Capabilities component feature to tailor Web content based on a browser's capabilities. For example, you can determine whether a user's browser supports frames, and if not, substitute appropriate Web content. For more information, see the Using COM Components module of the ASP Tutorial.
Monitor user preferences and behavior | You can use ASP to place cookies, small text files stored on the user's browser by the server, to determine which part of the Web site a user is looking at and how long that user lingers on certain Web pages. For more information, see Managing Sessions.
Obtain user feedback | Use the ASP Form and QueryString collections to gather user input from an HTML form. These collections simplify the creation of Web sites that process user feedback, such as a departmental bulletin board, an online survey, or a data retrieval system. For more information, see Processing User Input.

© 1997-2001 Microsoft Corporation. All rights reserved.