ASP for newcomers, common questions ~~

xiaoxiao2021-03-06  91

1. Problem: Is ASP a programming language?

A: ASP is not a programming language, but an development environment. The ASP provides an environment that executes instructions on the server, which uses special symbols () to distinguish between the commands that must be translated by the server to the client. The instructions that it can perform include HTML languages, Microsoft Vbscript, and Microsoft JScript, so you can make a powerful web application.

2. Problem: Have multiple Web sites on the web server, can I use PWS?

A: You can only accommodate a Web site on the PWS. In order to accommodate multiple web sites on the same computer, you need to use Windows NT Server or Windows 2000 Server / Professional and IIS.

3, question: How to use 6 built-in ASP objects?

A: The ASP provides multiple embedded objects that can be directly accessed and used in the instructions without the establishment. These six objects mainly include: request, response (response) object, work phase (session) object, Application Object, Server (Server) Object, Cookies object, Server object in these six objects (Server) objects can load other components, which can extend the ability of the ASP.

With the object established by Server.CreateObject, its lifecycle begins when it is established, ending at the end of its webpage. If you want to use the object across web pages, you can record the object established by Server.CreateObject with the Session object.

4. Problem: Why do you appear when using Response.Redirect: "Total error, the HTTP title has been written to the User Browser, and the modification of any HTTP title must be" before writing "?

A: Response.Redirect You can transfer web pages to another page. The syntax structure used is: Response.Redirect URL, where the URL can be relative address or absolute address, but use in IIS5.0 Difference.

An error occurred before any data is not output to the client browser before any data is output. Here, the so-called data includes HTML, such as , , etc., which has been improved in IIS5.0, and the buffer is open by default by default in IIS5.0, such an error is not Recovery.

There is a buffer attribute in the Response object, which can set the site to transfer the data to the client immediately after processing the ASP, but setting this property must also be used to send any data to the client.

For insurance, no matter what ASP run platform, start writing <% response.buffer = true%> on the page, set the buffer to open, such an error will not happen.

5, question: Is there any impact on the transmission of web pages?

A: In a relatively large web page, the first part may have some delay in the browser, but the speed of the entire web page is more than the buffer is fast.

6. Problem: Can the query string value when there is no form commit? The Request.QueryString collection is available?

A: The Request object is used to read the browser's data, in addition to reading the contents of the form field, can also be used to read the parameters included in the URL, regardless of how the request string is added to the link address to Request There is no difference. Use the GET method to submit a form or follow all the values ​​in the link query string of additional query strings, you can use the request.QueryString collection. 7. Problem: I wrote a lot of comments in the ASP script, will this affect the speed of the server to process the ASP file?

A: In the process of writing the program, the comment is a good habit. Testing abroad, the overall performance of ASP file with excessive annotation will only fall by 0.1%, which means that the performance of the server will decrease in the actual application.

8. Problem: Do you need <% @ language = VBScript% in each ASP file?

A: Use <% @ language = VBScript%> code to notify the server to write programs now using VBScript, but because the ASP's preset program language is VBScript, it is ignored that this code can also operate normally. However, if the script language of the program is JavaScript, you need to indicate the scripting language used in the first line of the program.

9. Question: Is there any "option explicit" in every ASP file?

A: In practical applications, the concept of VBScript variables has been blurred, allowing the variables to be used directly without using the DIM declaration variable, but this is not a good habit, which is easy to cause the program error because it may be repeatedly defined. We can use the Option Explicit statement in the program so that when you use a variable, we must first declare it. If you use the declared variables, the program will be wrong when running.

Practice proves that "Option Explicit" in ASP files can make program error chances to minimize and will greatly improve overall performance.

10. Problem: What safety measures do you have when running an ASP file?

A: ASP provides a good code protection mechanism, all ASP code executes only to the client code execution results in the server side. But still do not exclude malicious people deliberately destroying the web server, so pay more attention to security issues when writing ASP files.

Although the file is introduced into INC as an extension in the ASP, it is still recommended to use ASP as an extension of the lead file. When these codes run on the Web Server in the security mechanism, simply enter the address of the introduction file on the address bar (INC extension), you can browse the contents of the introduction file, which is due to the Web Server, This file is displayed in the source code if it is not defined to parse a type of (e.g., INC) dynamic connection library.

Also, don't put the database file inside the site structure, so that after the malicious person gets the database path, you can easily get the database, and then change the database content. A preferred approach is to establish a data source name DSN (Date Source Name) for the database, store information about connecting to the specified data provider, including: "database, the physical location of the database, is used to access the database for the driver of the database. Any other parameters required to access the database driver ", you can directly access the DSN directly when database access is performed.

11, Question: What should I consider when a Web database management system?

A: When evaluating a web database management system, you must take into account the three aspects: multi-user problem; the established web database should be a relational; database security issues. 12. Question: What is ADO? How is it operating the database?

A: ADO's full name is ActiveX Data Object (ActiveX data object), is an optimized access to a dedicated object set, which provides a complete site database solution for ASP, which function on the server, providing database information Home content, by executing the SQL command, let the user enter, update, and delete the information of the site database in the browser screen.

ADO mainly includes three objects of Connection, Recordset, and Command, which are as follows:

Connection object: Responsible for opening or connecting to a database file; RecordSet object: Access content of the database; Command object: Upload actions to the database, and execute the SQL Server stored procedure.

13. Problem: Where is the difference between using the RecordSet object and the Command object to access the database?

A: The Recordset object requires the database to transfer all the data, then the amount of data will cause the network blocking and the load limit of the database server, so the overall execution efficiency will decrease. The SQL statement is called directly using the Command object, and the operation performed is done in the database server, apparently there will be high execution efficiency. Especially in the server-side stored stored procedures, the network traffic can be reduced, and the overall execution efficiency can be improved due to the prior grammatical analysis.

14. Problem: Do you have to create a Connection object for each RecordSet object?

A: You can use the same Connection object on different Recordset objects at the same time to save resources.

15. Question: What is the database management system (DBMS)?

A: Database To ensure the security and consistency of the data stored, a set of software must have a software to complete the corresponding management task, this group of software is the database management system, referred to as DBMS, DBMS varies from the system, but in general, It should include the following aspects:

Database Description Functions: Define global logical structures, local logical structures, and other database objects for databases; database management features: including system configuration and management, data access and update management, data integrity management, data security management; database Query and manipulating function: This feature includes database retrieval and modification; database maintenance features: including data introduction lead management, database structural maintenance, data recovery function, and performance monitoring.

In order to improve the development efficiency of the database system, the modern database system provides a variety of tools that support application development in addition to DBMS.

16. Problem: What are the current popular web database management systems?

A: The current popular Web database management system has Microsoft's SQL Server, Oracle, DB2, Sybase, and small-scale companies use Access.

17. Problem: What is the use of ADDNEW method using ADO in ASP and uses "Insert Into ..." statement? Which way is better?

A: ADDNew method is just encapsulated "Insert InTo" statement, so when you operate a lot of data, you will have a speed of using the SQL statement directly accelerated the speed of access data, because it reduces ADO "translation "Time, due to the operation performed by the SQL statement is done directly in the database server, especially when the amount of data is large. 18. Problem: Why is I use the standard insert record statement in ASP INSERT INTO BOOKS ("Kitty", "Kitty@263.com") will be wrong?

A: SQL (STRUCTURED Query Language / Structure Query Language) is a data query language developed by IBM in the 1970s, which has now become a standard for relational database query language. The SQL statement is a kind of English-based programming, which can be used to add, manage, and access the database.

The string when adding in the SQL statement can use dual quotation marks, but in ASPs, single quotes can be used to perform properly. Therefore, it should be written into INSERT INTO BOOKS (Name, Email) Values ​​('Kitty', 'Kitty@263.com').

19, question: What is an ActiveX control? Where can I get these ActiveX controls?

A: Microsoft ActiveX control is a reusable software component developed by software providers. In addition to the ASP's embedded object, additional installed ActiveX controls can also be used in ASP, which saves many valuable development time, which actually embeds a lot of ActiveX controls in ASP.

Using ActiveX controls, you can quickly add special features in the development tool. For example, using an ADROTATOR object to make an ad scrolling board, use the FileSystemObject object to use the Marquee object to implement scrolling text.

Now, more than 1,000 commercial ActiveX controls have developed ActiveX controls, such as C, C , etc., and Microsoft Visual Java development environment Microsoft Visual J . Once the ActiveX control is developed, the design and developers can use it as a pre-assembly component for developing a client. Use the ActiveX control in this way, users do not need to know how these components are developed, in many cases, even do not need to program their own programming, you can complete the design of the web page or application.

There are more than 1,000 commercial controls provided by third-party software developers. The Microsoft ActiveX Component Library (ActiveX Component Gallery) has related connections, which point to the various ActiveX controls provided by Microsoft and third-party developers. In the Microsoft ActiveX Component Gallery, you can find a list of companies developing the Internet Enhanced ActiveX control.

20. Problem: Why use strStartport = (Request.form ("CatMenu_0" statement to get the value of the start site in the form in the database can't be found?

A: This is because the value of the starting site may have spaces, such as "Hangzhou", but because the space exists, the value taken by the ASP program may be "Hangzhou", and only "Hangzhou" record in the database Of course, it is not found, the solution is to remove all the strings two spaces in the use of the TRIM function. The corresponding statement is: strStartport = Trim (Request.form ("CatMenu_0") 21, question: Data in ASP After the life cycle is over, several ways to reserve variable content?

A: Any operation that causes the end of the page, such as pressing the "Refresh" button of the browser, or turn off the browser, reopen it, will cause the end of the variable lifecycle.

If you want to reserve the contents of the variable when executed on the web page, you can use the Application object when you use the application. For example, you can use the Application object to make a counter for statistical sites.

The session object is the same as the Application object, and the contents of the variable can be stored at the end of the page, but the Application object is different, each online is an independent session object, simply that all online Internet users will only share an Application Object, but every online Internetony will have its own session object.

Application objects and session objects can help us record the information on the server, and the cookies object will record the information in the client with the cookies feature provided by the browser. One point to note that cookies is recorded in the browser, so the access is not as simple as accessing other ASP objects (information stores in the server side), as far as actual operation, only in the browser starts to browse Server A web page, and Server has not downloaded any data to the browser, the browser can exchange the cookies data with Server.

22, question: What should I do after the object is used?

A: After using the object, first use the Close method to release the system resources occupied by the object; then set the object value "nothing" to release the memory occupied by the object, otherwise it will cause the Web service site operational efficiency and even because the object is too much. Crash, the corresponding statement is as follows: Object .close set object = Nothing

23. Problem: How many ways to read the HTML's form field in the ASP file?

A: The Request object can read the contents of the HTML form field in addition to the parameters of the URL, and the syntax structure that is often used is as follows:

wherein the method of the two transmission of GET or POST, where POST is a method that allows a large amount of data, and the GET method The data to be transmitted is attached to the URL, and then serve the server together, so the amount of data transmitted will be limited, but the performance efficiency is better than the POST method.

Data can be sent to the server using the GET or POST method, and the corresponding method of receiving data using the request object is as follows:

GET: Request.QueryString ("Field Name") can also be written as a Request ("Field Name)) Post: Request.form (" Field Name "), you can also write a Request (" Field Name) 24, question: How to improve Use the efficiency of the Request collection?

A: When using the Request collection, this is much more slower than accessing a local variable because of a series of searches for related collections. Therefore, if you intend to use a value in the Request collection multiple times in the page, you should consider storing it into a partial variable.

25. Problem: You can also use VBScript in the ASP page, you can also use JScript, how is a mixed use script engine?

A: Although VBScript can be used in the ASP page, JScript can also be used. But use JScript and VBScript simultaneously on the same page, it is not desirable. Because the server must instantiate and try cache two (rather than one) script engine, this increases the system burden to some extent. Therefore, from performance consideration, multiple script engines should not be mixed in the same page.

26, question: When we set an ASP file, and in compliance with the grammar, enter the following address by the browser, or open the browse through the Explorer: c: /inetpub/wwrow/a.asp, there will be unable to run errors, And prompt the permissions that the file cannot be accessed, why not run the ASP file normally?

A: This is because the ASP file first requires the site to be "executed (script)" attribute; then enter the address according to the URL format, not the DOS format, we need to install it on the computer and start the web service platform, and ensure ASP Files are stored in the virtual directory of the web server, you can browse through the HTTP format, entered in the address bar of the browser: "http: //; Web site name (or site IP address) / ASP file name", back After the car can see the server to perform the ASP file in the browser.

转载请注明原文地址:https://www.9cbs.com/read-106978.html

New Post(0)