|
Let ASP determine whether cookies are enabled
|
Total Hit (3117) |
Most web sites heavily rely on client-side cookies. For example, ASP Sessions can work correctly only if the browser allows temporary cookies (that are not stored on disk). ASP doesn't provide any native method to understand whether cookies are enabled or not, but you can use the following code:
....Read More |
Rating
|
|
|
Quickly create HTML tables from an ADO Recordset
|
Total Hit (5913) |
The ADO Recordset object exposes the GetString method, which returns the values in the Recordset into a formatted string. Here's its syntax:
res = GetString([StringFormat As StringFormatEnum = adClipString], _
[NumRows As Long = -1], [ColumnDelimeter As String], _
[RowDelimeter As Str
....Read More |
Rating
|
|
|
Don't use implicit connections when opening a Recordset
|
Total Hit (5302) |
As most ADO developers know well, there are basically two distinct syntax for opening a Connection and then a Recordset: you can explicitly create and open a Connection object, and then pass it to the 2nd argument of the Recordset's Open method (or assign to the Recordset's ActiveConnection property
....Read More |
Rating
|
|
|
|
Understanding IIS Isolation Levels
|
Total Hit (3210) |
Internet Information Server introduced the notion "Isolation Level", which is also present in IIS4 under a different name. IIS5 supports three isolation levels, that you can set from the Home Directory tab of the site's Properties dialog:
Low (IIS Process): ASP pages run in INetInfo.Exe, the mai
....Read More |
Rating
|
|
|
Avoid querying the ServerVariables collection
|
Total Hit (5645) |
You can access a lot of useful information through the ServerVariables collection, but this has a price in terms of performance. More precisely, the first time you reference this collection in a page, IIS must collect all the data that is necessary to create the collection. All the subsequent refere
....Read More |
Rating
|
|
|
The MapPath method slows down execution
|
Total Hit (5214) |
The Server.MapPath method slightly shows down the execution of your ASP scripts, because IIS has to access some internal variables. For this reason you should try to avoid it if possible. In other words, you should code absolute physical paths in your ASP code, instead of using virtual paths that yo
....Read More |
Rating
|
|
|
Cache frequently used read-only data in Application variables
|
Total Hit (5153) |
Unlike Session variables, there is only one instance of each Application variable. This means that storing data in an Application variable - including memory-consuming data such as long strings or arrays - doesn't severily impact on system performance (unless you store strings with thousands and tho
....Read More |
Rating
|
|
|
Ensure that server-side debugging is disabled in production sites
|
Total Hit (5229) |
Before going to production, you should ensure that the server-side script debugging is off for your ASP application. In fact, not only does server-side debugging slow down your application, it also forces all ASP request to be served by the same thread. In other words, you don't take advantage of II
....Read More |
Rating
|
|
|
Don't mix script languages on the same page
|
Total Hit (5454) |
You should never use more than one script language on the same ASP page, for example by mixing pieces of VBScript with portions of JavaScript. The reason is that there is a limit to the number of script engines that ASP can cache.
When IIS processes an ASP file, it parses the script code and cac
....Read More |
Rating
|
|
|
Use Server.HTMLEncode for strings stored in a database
|
Total Hit (2863) |
If your ASP pages display strings stored in database fields, you should always process the strings with the Server.HTMLEncode method, otherwise the string won't be displayed correctly in the user's browser if it contains characters that have a special meaning to HTML, such as the quote ("), the less
....Read More |
Rating
|
|
|
Beware of the Dictionary object in ASP pages
|
Total Hit (5293) |
The Scripting.Dictionary object is marked as having a "Both" threading model, which means that you can freely assign it to a Session or an Application variable. However, the actual threading model for this object is "Apartment", which means that you should use it only at the page scope level. You ca
....Read More |
Rating
|
|
|
Tricks with Server.MapPath
|
Total Hit (3008) |
The Server.MapPath method can be used to retrieve several interesting properties about the running ASP application, for example:
«Code LangId=5»
' the current directory
currDir = Server.MapPath(".")
' the parent directory
parentDir = Server.MapPath("..")
' the application's root director
....Read More |
Rating
|
|
|
Using out-process components under IIS4
|
Total Hit (2834) |
By default IIS 4 doesn't permit to use the Server.CreateObject command with an out-process ActiveX EXE component. To do so, you must manually create the AllowOutOfProcCmpts registry value under the path HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W3SVC\ASP\Parameters, and set its value to 1
....Read More |
Rating
|
|
|
|
Cache frequently used read-only data in Application variables
|
Total Hit (5541) |
Unlike Session variables, there is only one instance of each Application variable. This means that storing data in an Application variable - including memory-consuming data such as long strings or arrays - doesn't severily impact on system performance (unless you store strings with thousands and tho
....Read More |
Rating
|
|
|
ISSUE : IIS6.0 prevents the upload of files more than +200 KB
|
Total Hit (3030) |
IIS6.0 prevents the upload of files more than +200KB. So you need to make some changes in the default IIS settings first.
«b»Background«/b»
For IIS6.0 users, the AspMaxRequestEntityAllowed property specifies the maximum number of bytes allowed in the entity body of an ASP request. If a Conten
....Read More |
Rating
|
|
|
Use Global.asa Metadata directive to access type libraries
|
Total Hit (2934) |
Most ADO statements require special constants to be passed as arguments to method calls, as in:
«Code LangId=5»
rs.Open "Authors", cn, adOpenForwardOnly, adLockReadOnly, adCmdTable
The above line is surely more readable than:
rs.Open "Authors", cn, 0, 1, 1
«/Code»
but for the fir
....Read More |
Rating
|
|
|
|
Force Download to client browser.
|
Total Hit (6010) |
Forces users to have choice of downloading a binary file. This was becomming a problem with Word documents - as they would either open within the browser or open externally. You may need to change the FileName variable.
«Code LangId=5» <%
Dim Stream
Dim Contents
Dim FileName
....Read More |
Rating
|
|
|
Large or nested include files can affect ASP performance
|
Total Hit (5538) |
All include files appear to the ASP processor as belonging to the main ASP file, therefore they are read in memory and parsed as if they were physically pasted into the main ASP file. Therefore, while you should use include files for holding commonly used routines, you should be aware that the longe
....Read More |
Rating
|
|
|
Miscellaneous tips for improving ASP performance and robustness
|
Total Hit (6116) |
Here's a collection of quick-and-dirty tips for improve the performance and the robustness of your ASP applications:
Use the Option Explicit directive to ensure that all variables are correctly declared and scoped. Mistyping a variable name is one of the most frequent causes of bugs inside ASP
....Read More |
Rating
|
|
|
Redirect the browser when the output has already been sent
|
Total Hit (3710) |
If from an ASP page you try to use Response.Redirect after having written anything to the browser, you'll get an error saying that the page's headers have already been written. To avoid this you should put the code that checks if the browser needs to be redirected to another page at the very beginni
....Read More |
Rating
|
|
|
HOW TO: Use Database and ASP Sessions to Implement ASP Security
|
Total Hit (3762) |
This step-by-step procedure illustrates how to implement forms-based security for Active Server Pages (ASP) applications. You can use this mechanism when your application is secure, when you want to allow only authenticated users, and when the users are not part of your internal domain (such as Inte
....Read More |
Rating
|
|
|
ASP Including Files
|
Total Hit (1140) |
You can insert the content of one ASP file into another ASP file before the server executes it, with the #include directive. The #include directive is used to create functions, headers, footers, or elements that will be reused on multiple pages.
|
Rating
|
|
|
Download multiple files in one http request
|
Total Hit (2805) |
HTTP protocol was designed to send one file per one request. Sometimes you will need to send more files - usually when a client selects several files for download and the files have to be delivered to the client. I created ASP sample which will do such task - the sample is located at http://www.pstr
....Read More |
Rating
|
|
|
|
Downloading Files with VBScript and ASP
|
Total Hit (1529) |
The primary use for a system like this is to allow downloading of any TEXT based file that would normally be served via a client's browser and be unable to be downloaded. This system works great when setting up downloads for files with the following extensions: *.txt, *.htm, *.html or *.asp . This s
....Read More |
Rating
|
|
|
ADO Tutorial
|
Total Hit (3869) |
«big»«u»«b»ADO Tutorial«/b»«/u»«/big»
«b»ADO Introduction«/b»
This chapter explains what ADO is, and how it can be used.
«b»ADO Database Connection«/b»
This chapter explains how to connect to a database using ADO.
«b»ADO Recordset«/b»
This chapter explains how to access an ADO Recordset
....Read More |
Rating
|
|
|
How To Manipulate Text Files in an ASP Page
|
Total Hit (1137) |
This article describes how to create, write, read, move, copy, and delete text files from within an Active Server Pages (ASP) page.
You may want to use a text file for the sake of simplicity (when a database or more complicated file format may be excessive) or when prior data exists in the form o
....Read More |
Rating
|
|