Go: ASP Guide

Source: Internet
Author: User
Tags iis include naming convention variables require knowledge base ntfs permissions
ASP Guide


Brief introduction
The success of an Active Server Page (ASP) application often depends on trade-offs between architecture and design. This trade-off is very difficult, given the breadth of the ASP technology and the inherent complexity of the current application. In this article, I will provide you with specific guidelines to help you successfully develop an ASP-based application.


--------------------------------------------------------------------------------
From the past successful development model experience, we have summed up the following principles.
--------------------------------------------------------------------------------

I have organized the guidelines into a set of development principles. When evaluating solutions and technologies, you can apply the following guidelines to help you make decisions. The following principles are the cumulative experience I have gained from a successful development model for a long time.

Principle 1: Adopting a standard approach
Establishing naming conventions and standardizing the directory structure can help you significantly improve the readability and maintainability of your ASP applications. Although there is no formal standard for ASP applications, many developers have established some common approaches. Here, I'll share some more general ways with you.

Because the ASP technology relies on the scripting engine for its work, and the script is of a less-than-rigorous nature, the naming convention is also vague. In a very strict type of language, a variable is declared according to its actual type. When using ASP technology, you typically declare variables in ASP code in terms of how variables are processed, rather than their actual data types. For example, when using Visual Basic (R) scripting Edition (VBScript), even though all VBScript variables are variants, you will still declare the success flag as bsuccess (b for Boolean) instead of Vsuccess (v represents a Variant).

The following table is a list of common naming conventions.

Variable prefix:

Examples of variable variables used by prefixes
B or bln Boolean bsuccess
C or cur Currency camount
D or Dbl Double dblquantity
DT or Dat Date and time dtdate
F or Flt Float Fratio
L or LNG Long lmilliseconds
I or int Integer icounter
s or str String sname
A or arr Array ausers ()
O or obj COM Object opipeline


Variable prefix for database object:

Examples of variable variables used by prefixes
CNN Connection Cnnpubs
RST Recordset rstauthors
CMD Command cmdemployee
FLD Field Fldlastname


Scope and Prefix usage:

Prefix description
G_ is created in Global.asa.
M_ is local to ASP pages or in Include files.
(no prefix) non-static variable, prefix is local to procedure


An article in Knowledge Base (KB) "Q110264 info:microsoft Consulting Services naming conventions for Visual Basic" provides genuine insight into naming conventions See.

Use the directory structure wherever possible to provide a consistent location for your individual application parts. The actual directory structure of your application is, of course, up to you, but it is usually to place images, documents, include files, and components separately in separate directories. The following is an example of a simple ASP application directory structure.

Directory Structure Example:

\simpleaspapp
\docs
\images
\includes
A good directory structure allows you to selectively apply NTFS permissions. You can also use relative paths from within an ASP application. For example, you can use the following code to refer to the include file in the Includes directory from the Default.asp page located in the Simpleaspapp directory top.asp:

./includes/top.asp
Note that the extension of my include file is. asp instead of. Inc. This is done for security reasons, and it is possible to use the. asp extension (instead of. Inc), and it can also be used for color encoding in Visual InterDev (R).

For additional tips and tricks on structured ASP applications, see the article "ASP conventions".

Principle 2: Designed to run under the service
The ASP will run under the service. When designing an ASP application, you immediately face security and threading problems that you will not encounter in your desktop application. In a desktop environment, only single-threaded execution, which runs as an interactive user, is typically handled, and access to the current desktop system is granted. In Internet Information Services (IIS), multiple client threads that simulate different user environments call your application, and your application is limited to the system desktop.

What does this mean for you? Learn about IIS security mode. Also remind you that just because something works correctly under the Visual Basic IDE does not mean it can run safely in ASP technology. The Visual Basic IDE does not accurately simulate the run-time environment. Common design errors include the use of the user interface in ASP technology. OCX control, using threads to say unsafe components, and using components that require special user contexts. One of the simplest things to avoid is trying to access HKEY_CURRENT_USER (HKCU) registry entries from your application (for example, do not invoke the GetSetting and savesetting functions of Visual Basic, all of which depend on HKCU). Also, do not show message boxes or other dialog boxes that require user interaction.

The following article is a pretty good primer on security and validation issues in ASP technology:

"Authentication and security for Internet Developers" (English)
"Q172925 info:security Issues with Objects in ASP and ISAPI Extensions" (English)
Principle 3: Encapsulating business logic
ASP technology provides a representation service by generating HTML output. In short, it generates a user interface. You need to separate the business logic from the ASP presentation script. Even if you do not use COM components to separate business logic from ASP code, you should at least separate business logic into functions and include files to improve maintainability, readability, and reusability. You can also appreciate the benefits of modular design methods when troubleshooting and isolation issues are required.

Calling functions and methods inside of a script avoids code whack and adds structure to an ASP application. The following example illustrates the separation of logic into a method call from ASP code:

lt;% Main ()
Mybizmethod ()
...

Sub Main ()
GetData ()
Displaydata ()
End Sub
%>
This principle can be applied when using a technology that contains ASP features. Here's an example of using Visual Basic WebClass to illustrate how to use this principle:

Because the Web



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.