How to write a good ASP application

Source: Internet
Author: User
Tags arrays connection pooling file size include new features odbc connection variables msmq
Program


How to create robust, accurate, maintainable, and performance-Good ASP applications? What do you want to do? Not doing what? In this paper, the main check-points (check point) is given in the form of outline.

What is ASP

Active Server Page, abbreviated as ASP, is:

L Connect user Interface (HTML) and business logic (Business Logic);

• Provide consistent, easy-to-use, stateful, web-based clients;

• Provide an application environment for Web applications that require transactional processing.

ASP is not:

• Where business logic is implemented (Business Logic); Business logic should be implemented through COM +, MTS, or the database.

Users of ASPs should have the following lessons:

• Develop applications, rather than developing an orphaned ASP page;

• Caching of inputs and outputs;

• test before release;

L Selective and good components;

• Reduce access to the database: The result of a cached transformation;

• Use of MSMQ to handle work with time delays;

Site design
What do you want to provide for your site?

U Information Architecture: 80/20 guidelines;

U site navigation;

U page layout;

U usability;

N use alt and title attributes;

n Do not use the image or image map navigation;

You are suitable for most of the lower-version browsers, considering their support for ActiveX, RDS, XML, DHTML, Java applets;

U screen resolution and number of screen colors

Does n support WebTV, PDA ...?

n Sets the width and Height properties of the IMG.

U non-browser access, such as Automatic Robot (Spider);

U using frames (frame)?

u use cookies for personalization;

U avoid bad connections;

u use META tags;

U content audit;

U content search;

U results Feedback: User feedback and tracking;

u reduce download time;

Three-layer, four-storey application design

Readability, maintainability
u use annotations;

u use <%option explicit%>; in VBScript scripts

U Store SQL strings using string variables: Easy to debug;

u use Server.MapPath and relative paths;

u use Adodb.inc or <!-metadata typelib=somelib file=somedll--> to refer to constants instead of using constant values directly.

U Specify the default parameters of ADO calls to avoid errors;

U use libraries or parts to encapsulate code.

The right approach:

u use Server.URLEncode

U error capture and handling

Internationalization:

u use <%CodePage%>

u use Session.CodePage

U in IIS5.0, Response.Write support UTF8

Other:

U reuse code with #include

U Use paging technology

Site Security:

U Customer Authentication

U Input Validation

U #include file do not use. Inc suffix, use. ASP or settings. Inc Application Mappings

U store MDB files in a non-web path;

U do security management with ADSI

Session and Application Status
Use of Session:

U is very convenient to use but very problematic;

U HTTP is a stateless protocol;

U design Shopping carts are particularly useful;

U is not conducive to scalability design (scalability);

u use <%EnableSessionState=false%> in pages that do not require session

U avoid using session as completely as possible;

U is not suitable for multiple Web server situations;

U some parts enable session to run in a single threading mode, reducing throughput;

u consumes memory;

U session has timeout problem

You need the client's browser to open cookie settings;

U do not save the recordset in the session, or cache the connection object;

u do not use empty session_onend in Global.asa;

U option:

n Cookies

U Direct State code: Simple, easy, unsafe

U back-end Database ID as status value

N QueryString Parameter

n like Amazon's URL way

N Hidden Forms

Application variable:

U Share variables

U cannot be saved persistently

U no more than one Web server, unless you are only a read-only variable.

Cache
U is ideal for static content

u do not use response.expires=0, use negative numbers:

n response.expires=-10000;

n Response.AddHeader "Pragma", "No-cache"

Uresponse.addheader "Cache-control", "No-store"

U Server Cache

U Proxy Cache

U Client Cache

Parts
U performance

U Scalability

U Split business logic and page performance

U is reused by ASP or other environment

U transaction Processing

U type safety

U Access Operating system features

U Protect intellectual Property rights

u use Server.CreateObject in the following situations:

N MTS Transaction Processing

N Context Security

n ASP Internal Parts

N OnStartPage, OnEndPage

u use <object runat=server> Delay object Initialization

Do you want to save to the session or application variable

U

Performance
n Response Buffer: response.buffer=true

N Close Connection and: Set connection=nothing

n using local Variables

N Replace Server.CreateObject with <object >

n do not use session and application variables

n Do not store COM objects in session or application variables

n Turn off script debugging

n Avoid repeating string additions

n Use response.isclientconnected at the top of a time-consuming page

N Using MSMQ

n Do not store large arrays in session or application

n Do not ReDim arrays

n assigns an object of a collection type to a temporary variable

n Reduce the maximum number of threads in the microprocessor (run Regedt32, hkey_local_machine\system\ currentcontrolset\services\w3svc\asp\parameters, Increase the ProcessorThreadMax, reduce the value, see the performance change, or increase the value. )

n Sets the AspScriptEngineCacheMax so that it equals the number of processorthreadmax*cpu. The default is 30; (Under the System path: \system32\inetsrv/adminisamples, type adsutil.vbs, set/w3svc/aspscriptenginecachemax);

n Reduce session.timeout;

N in MMC, set the ASP application buffering to be valid.

To give some work to the client:

N CSS, DHTML

N XML

N RDS

n Remote Scripting

N Xmlhttp

N Client-side validation

n Reduce File size

N Avoid HTTPS and SSL whenever possible

N Test Performance using Response.End

N

Database
n Reduce access to database access;

n the result of the buffer transformation;

n Use ODBC connection pooling and OLE DB resource pools;

n Use System DSN or non-DSN, do not use DSN or file DSN;

n makes ADO run in dual-threading mode (both-threaded): Makefre.bat;

n Use the Field object of ADO;

n GetString or GetRows relatively fast;

n rds and XML to marry the load to the client;

n Do not use SELECT *, write the fields out;

n Use SQL Server 7 as much as possible and do not use access;

n Use SQL Server features: stored procedure, Job, Join, sort, group

n Use SQL analysis to optimize SQL performance

N Using indexes

n Use name-pipes locally, use sockets remotely

N precisely specifies the command Type

New features of IIS 5
n A reliable reboot

N ASP Performance Improvement

n Server.Transfer better than Server.redirect

N Server.Execute

N Server.GetLastError




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.