|
Avoid OnEndPage in ASP components under IIS 5
|
Total Hit (5222) |
As explained elsewhere in this knowledge base, you are suggested not to rely on the OnStartPage method to get a reference to the main ASP objects, if your component is to be run under IIS 5. However, if you do run such a component under IIS 5, at least you should ensure that it doesn't expose the On
....Read More |
Rating
|
|
|
Avoid querying the ServerVariables collection
|
Total Hit (5658) |
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
|
|
|
Buffering is on by default in IIS 5
|
Total Hit (5344) |
You can speed up ASP by adding the following statement at the beginning of an ASP page:
Response.Buffer = True
This statement must be executed before any HTML text is sent to the client. When buffering is on, ASP sends data to the client browser only when the page has been processed, or when
....Read More |
Rating
|
|
|
Cache frequently used read-only data in Application variables
|
Total Hit (5165) |
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
|
|
|
Cache frequently used read-only data in Application variables
|
Total Hit (5551) |
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
|
|
|
Create a GUID from ASP using SQL Server
|
Total Hit (6109) |
At times you may need to create a GUID from ASP, for example when assigning unique IDs to users that are visiting your site for the first time. While you can generate new GUIDs from VB quite easily with a call to the CoCreateGUID API call (as explained elsewhere in the Tip Bank, see below), you can'
....Read More |
Rating
|
|
|
Don't mix script languages on the same page
|
Total Hit (5471) |
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
|
|
|
Don't use implicit connections when opening a Recordset
|
Total Hit (5320) |
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
|
|
|
Ensure that server-side debugging is disabled in production sites
|
Total Hit (5243) |
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
|
|
|
Large or nested include files can affect ASP performance
|
Total Hit (5550) |
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
|
|
|
Let ASP determine whether cookies are enabled
|
Total Hit (3126) |
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
|
|
|
Redirect the browser when the output has already been sent
|
Total Hit (3723) |
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
|
|
|
Split large HTML tables in smaller ones
|
Total Hit (2932) |
In general, a browser can't render an HTML table before the closing &/TABLE> tag is received. This means that the end user might wait for several seconds before a table result is displayed. The easiest way to have results appear as soon as they are available is subdivide a large HTML table into many
....Read More |
Rating
|
|
|
The MapPath method slows down execution
|
Total Hit (5225) |
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
|
|
|
Tricks with Server.MapPath
|
Total Hit (3018) |
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
|
|
|
Two ways to access ASP objects from within a component
|
Total Hit (8884) |
You can write ASP components that work under any version of IIS by adding a special public method, named OnStartPage, to the public class module of the ActiveX DLL project. This method is then called by IIS whenever a script instantiates an object through the Server.CreateObject command. This is the
....Read More |
Rating
|
|
|
Understanding IIS Isolation Levels
|
Total Hit (3220) |
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
|
|
|
Use Global.asa Metadata directive to access type libraries
|
Total Hit (2943) |
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
|
|
|
Use Response.IsClientConnected after long queries
|
Total Hit (3032) |
When you perform a complex and time-consuming query in your ASP program, you should periodically test whether the client is still connected, using the IsClientConnected method of the Response object, as in :
«Code LangId=5»
' a lenghty query here
' ...
' check whether the client is connected be
....Read More |
Rating
|
|
|
Use Server.HTMLEncode for strings stored in a database
|
Total Hit (2873) |
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
|
|
|
Using out-process components under IIS4
|
Total Hit (2844) |
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
|
|
|
|
|
ISSUE : IIS6.0 prevents the upload of files more than +200 KB
|
Total Hit (3039) |
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
|
|
|
HOW TO: Use Database and ASP Sessions to Implement ASP Security
|
Total Hit (3770) |
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 (1147) |
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
|
|
|