Answer | question text:
(The Woods June 07, 2000 14:12)
Question: How to protect your own ASP source code does not leak?
A: Download Microsoft's Windows Script Encoder to encrypt the ASP scripts and client JavaScript, VBScript scripts. After client script encryption, only IE5 version can be executed, server-side script encryption, only the server installed Script Engine 5 (installed IE5 can) to explain the execution.
Question: Why Global.asa files always don't work?
A: It is only valid to place the Global.asa file in the root directory of a site in the Web publishing directory, and it will not work in a subdirectory of the publishing directory. Alternatively, you can use the IIS4 Internet Service Manager to set a subdirectory as a site.
Question: Why does ASP file always not explain execution?
A: There is no permission to script an ASP file on the IIS server, so the ASP file is not interpreted as a script code by the Web server and is considered a general paging file. It is recommended to create an ASP directory in the Web publishing directory, store all ASP files in this directory, and give the ASP directory the ability to interpret the script.
Problem: Error using Response.Redirect (URL) in ASP file "The HTTP headers are already written to the client browser. Any HTTP header modifications must is made before writing page content ", how can i solve it?"
A: This error is written to the client browser after the HTTP header is written to the page content. Any changes to HTTP headers must be made before the page content is written, by adding Response.Buffer = True at the beginning of the ASP file and adding Response.Flush at the end of the file.
Question: Why does the session sometimes disappear?
A: The session is like a temporary cookie, except that its information is stored on the server (the client is SessionID). The session variable disappears with several possibilities, such as: The user's browser does not accept cookies because the session relies on cookies to track users; The session expires after a period of time, defaults to 20 minutes, and if you want to change, you can set up Microsoft Management Console's web directory→properties→virtual directory→application Settings→configuration→app Options→session the Timeout option to change the timeout for the session, or you can set it in an ASP script, such as SESSION.TIMEOUT=60, to set the timeout time to 60 minutes.
Question: How do you know something about a visitor?
A: The type of visitor's browser is obtained through Request.ServerVariables (″http-user-agent″); Request.ServerVariables (″remote-addr″) can obtain the visitor's IP address , and the language environment of the visitor can be obtained by Request.ServerVariables (″http-accept-language″).
Question: How can I transfer query string from one ASP file to another ASP file?
A: The previous ASP file adds the following code: Response.Redirect (″second.asp?″& request.servervariables (″query-string″)).
Question: How to control cookies in ASP?
A: If you want to write Cookies available: response.cookies (″ coookies name ″ to be written) = Pending write Data. Read cookies are used: Read the data =request.cookies (″ the name of the cookie to be read ″).
Note that the Response.Cookies program segment that writes cookies must be placed before the 〈html〉 tag, and no other HTML code can be available. In addition, cookies must be used expires set the expiration date, cookies can be really written to the client hard disk, otherwise only temporary.
Question: How do I use ASP to send mail?
A: Users should install the SMTP service feature of the Windows NT Option Pack. The implementation 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: Must the ASP connect with the database to set up DSN on the server side?
A: Not necessarily, there are two ways for ASP to connect to the server's database, one to establish a connection through DSN, and the other to not establish a connection with DSN. Connecting to a database through a DSN requires the server's system administrator to set a DSN in ODBC in the server's control Panel. If you do not set up DSN on the server, you can access the database as long as you know the database file name (such as Access, Paradox, FoxPro database) or a data source name (such as a SQL Server database), providing the parameters you need to connect directly.
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 (″selectfrom Authors″)
Question: How do I pass a variable from one page to another?
A: Use hidden form types to pass variables.
〈form method=″post″action=″mynextpage.asp″〉
〈% for each item in Request.Form%〉
〈input Namee=″〈%=item%〉″type=″hidden″
Value=″〈%=server. HTMLEncode (Request.Form (item))%〉″〉
〈% Next%〉
〈/form〉
Use session to save variables.
〈%session (″bh″) = Request.Form (″bh″)%〉
Save variables with querystring.
〈a herf=″action.asp?bh=10″〉 Query 〈/a〉
〈%request. QueryString (″bh″)%〉
Question: How to achieve online population statistics with ASP?
A: The number of people online refers to the number of visitors in a period, the length of time is set by the designer.
During this period, the total number of different IP visits to this site is the current number of online. In ASP, the session object is used to implement statistics, and the implementation code is as follows:
Golobal.asa file
〈script language=″vbscript″runat=″server″〉
Sub Session-onstart
Application (″online″) =application (″online″) +1
End Sub
Sub Session-onend
Application (″online″) =application (″online″)-1
End Sub
Sub Application-onstard
Application (″online″) =0
End Sub
Sub Application-onend
Application (″online″) =0
End Sub
〈/script〉
online.asp File Contents
〈% tmp=application (″online″)
TMP=CSTR (TMP)
Dim disp (20)
Dim images (20)
Dbbits=len (TMP)
F