Use ASP FAQ

zhaozj2021-02-08  245

(Author: woods, 2000 at 14:12 on June 7)

Question: How to protect your ASP source code does not disclose?

A: Download Microsoft's Windows Script Encoder, encrypts the ASP scripts and client JavaScript, VBScript scripts. After the client script is encrypted, only the version of IE5 is only executed. After the server-side script is encrypted, only Script Engine 5 (IE 5) is installed on the server to explain the execution.

Question: Why does global.asa files do not do?

A: It is valid only if you put the global.asa file in the root directory of a site, it is valid, and it does not work in a subdirectory of the publishing directory. Alternatively, IIS4 can be used to set a subdirectory as a site using IIS4.

Question: Why does the ASP file do not explain?

A: There is no permission to the ASP file on the IIS server, so the ASP file is not interpreted by the web server as the script code, and is used as a general page file. It is recommended to establish an ASP directory in the web publishing directory, put all ASP files in this directory, give the ASP directory to script interpretation permissions.

Problem: Errors when using Response.Redirect (URL) in the ASP file, "The Http Headers Area, Any Http Header Modifications Must Be Made Before Writing Page Content", how to solve it?

A: This error is written to the customer browser after the HTTP title is written. The modification of any HTTP title must be performed before writing page content, and the solution is to add Response.Buffer = True at the beginning of the ASP file, and add response.flush on the end of the file.

Question: Why will sessions sometimes disappear?

A: The session is very like temporary cookies, but its information is saved on the server (Sems SemiID is saved on the client). Several possibilities disappear, such as: The user's browser does not accept the cookie, because session depends on cookies to track users; session expired after a while, default 20 minutes, if you want to change, you can set Microsoft Management Console's Web Directory → Properties → Virtual Directory → Application Settings → Configuration → App Options → Session Timeout option to change the timeout time of the session, or set in the ASP script, such as session.timeout = 60, set timeout time For 60 minutes.

Question: How can I know some information about visitors?

A: Get the type of visitors browser through Request.SerVariables ("http-user-agent"); Request.SerVariables ("remote-addr") gets the visitor's IP address; and the visitor's locale can pass through Request .Servervariables ("http-accept-language") is obtained.

Question: How can I transfer Query String from an ASP file to another ASP file? A: The previous ASP file is added to the following code: Response.Redirect ("Second.asp?" & Request.serverVariables ("query-string"))).

Question: How do I control cookies in ASP?

A: If you want to write to the cookies available: Response.cookies ("The Cookies Name to be written") = The data is written. Reading cookies Use: Read Data = Request.Cookies ("Cookies Name").

Note that the response.cookies program segment written to the cookies must be placed before the tag, and there is no other HTML code. In addition, you must use Expires setting validity period in cookies, and cookies can really write into the client hard drive, otherwise just temporary.

Question: How do I achieve an email with ASP?

A: The user needs to install the SMTP Service feature of Windows NT Option Pack. The code is as follows: <%

Set mail = server.createObject ("cdonts.newmail")

Mail.to = "abc@xxx.com"

Mail.from = "YourMail@xxx.com"

Mail.subject = "theme"

Mail.Body = "e-mail content"

Mail.send

%>

Question: Is the ASP and database connections must set DSN on the server side?

A: Not necessarily, the ASP has two ways to connect to the server, one is connected to the DSN, and the other does not have a DSN to establish a connection. Set a DSN in the ODBC in the server's system administrator to the server's control panel via the DSN connection database. If DSN is not set on the server, just know the database file name (such as Access, Paradox, FoxPro database) or data source (such as SQLServer database), you can access the database directly, you can directly provide the parameters required to connect.

The connection code is as follows:

Set conn = server.createObject ("adoDb.connection")

CONNPATH = "DBQ =" & Server.MAppath ("YourTable.mdb")

Conn.open "Driver = {Microsoft Access Driver (.mdb)};" & connpath

SET RS = conn.execute ("SELECT  from autom")

Question: How do I transfer variables from one page to another?

A: Use the Hidden form type to pass the variable.

<% For each item in request.form%>

Value = "<% = Server.htmlencode (Request.form (item))%>>>>>

<% Next%>

Use the session to save the variable.

<% Session ("BH") = Request.form ("BH")%> Save the variable with querystring.

Query

<% Request. QueryString ("BH")%>

Question: How to use ASP to implement online number statistics?

A: The number of online people refers to the statistics of visitors in a period, and the length of time is set by designers.

In this period, each different IP accesses the total number of this site is the current number of people. In ASP, use the session object to implement statistics, implement the code as follows:

Golobal.asa file