Page #23 (Chapter 3 - Building ASP Applications)

Chapter 3 - Building ASP Applications

Visual Basic Developers Guide to ASP and IIS
A. Russell Jones
  Copyright 1999 SYBEX Inc.

Understanding the Structure of an ASP Application
An application, to the ASP engine, is the set of all files and subdirectories within a directory that contains a global.asa file. Most ASP applications consist of ASP files and include (.inc) files, both of which can be any mixture of HTML, code, and graphics files; however, you can freely intermix ASP files with HTML files or any other file type that the server understands.
Figure 3.1 shows the directory structure for a typical ASP application.
The top-level directory of the structure contains the global.asa file. The global.asa file defines the root directory for an application. The first time a user requests an ASP file in any directory in the application, the ASP engine traverses the tree upward until it finds a global.asa file (or until it reaches the root Web directory). This is important, because if you nest applications, the global.asa file that will be run for any particular user's request depends on which file the user requests first. Because you can't control a user's first request, don't nest ASP applications unless you have a good reason.
On IIS 4, you need to take an additional step to create a Web application: You must tell IIS that the virtual directory containing the global.asa file is the root of a Web application. You'll see more about that later in the section "Creating a Self-Modifying ASP Application."
The global.asa file always runs first, regardless of which file was requested. At this point, you can gain control of the request by redirecting the browser to the page of your choice in the global.asa file. As people use your application, they're likely to save bookmarks or favorites. These bookmarks may or may not point to the starting file in your application. If your application depends on users starting at a particular point, or if you have security requirements, you should route users to the appropriate page by redirecting them in global.asa.
The application shown in Figure 3.1 contains several ASP files as well as two subdirectories, images and include. No single directory structure fits all applications; you can put all the files in a single directory if you wish. In practice, though, it's much easier to build and maintain the application if you arrange files according to their function.
  Note The virtual Web root and the ASP application root do not have to be the same.
For example, you might have a single global.asa file that applies to several ASP applications. You could place that global.asa file in a directory and then define each subdirectory in that directory as a virtual root, named according to the application. The directory structure in Figure 3.2, for example, contains four applications: 401k, Paycheck, Retirement, and Timesheet.
The highest-level directory, called HR Applications, contains the global.asa file. Whenever a user attaches to any of the four applications, the ASP engine climbs the directory tree until it reaches the HR Applications level, where it finds the global.asa file. One reason to set up an application in this manner might be that all four sites share security arrangements. Another reason might be that all four applications share a common database connection or other data, and you want to initialize that information in the global.asa file.



Visual Basic Developer[ap]s Guide to ASP and IIS
Visual Basic Developer[ap]s Guide to ASP and IIS
ISBN: 782125573
EAN: N/A
Year: 2005
Pages: 98

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net