ASP Coding Optimization Skills 8 (Turn)

Source: Internet
Author: User
Tags iis urlencode
ASP (Active Server Page) is an ISAPI based (Personal WEB server) &iis (Internet Information Server) platform launched by Microsoft Corporation (PWS) ( INTERNETSERVICEAPI) Principle of Dynamic Web page development technology, is increasingly mature and perfect. Here are just some simple discussions about code optimization.
1. Declaring VBScript variables
In ASP, there is strong support for VBScript, the ability to seamlessly integrate VBScript functions, methods, so as to extend the existing functionality of the ASP to provide a great convenience. Since the concept of variable types has been blurred in ASP, many programmers are wont to declare VBScript variables in the process of interacting with VBScript, thus aggravating the resolution burden of the server and affecting the response request speed of the server.
For this reason, we can force a user to declare a variable in VBScript just as a variable declaration is enforced in VB. The implementation method is to place <% option explicit%> at the beginning of the ASP program.
2, the URL address to encode
In our use of ASP dynamically generated with a parameter URL address and jump, in IE parsing is normal, but in the Netscrape browsing there are errors as follows:
HTTP Error 400
Bad Request
Due to malformed syntax, the request could not being understood by the server.
The client should not repeat the request without modifications.
The workaround is to URL-encode the generated URL parameters using the UrlEncode method of the ASP built-in server object, as shown in the following example:
<%
Url= "Xur.asp"
Var1= "username=" & Server. UrlEncode ("Xur")
Var2= "&company=" & Server. UrlEncode ("Xurstudio")
Var3= "&phone=" & Server. UrlEncode ("021-53854336-186")
Response.Redirect URL & "?" & Var1 & var2 & VAR3
%>
3, empty the object
When you finish working with the object, you first use the Close method to release the system resources occupied by the object, and then set the object value to "nothing" to free the object from memory. That's when I crashed my IIS on a page by creating a recordset that hundred didn't empty the object. The following code uses the database content to create a drop-down list. The code example is as follows:
<% mydsn= "Dsn=xur;uid=xur;pwd=xur"
Mysql= "SELECT * from authors where au_id<100"
Set Conntemp=server.createobject ("Adodb.connection")
Conntemp.open MyDSN
Set Rstemp=conntemp.execute (MySQL)
If Rstemp.eof Then
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.