Recently, many readers have consulted us about ASP methods and some problems encountered in learning. Some of them are problems that beginners often encounter and face. In order to allow readers to learn more about ASP and effectively solve problems, we have collected some representative problems, I would like to list them and give them a one-to-one answer. I hope that I can help you learn ASP in this limited space.
1. Question: Is ASP a programming language?
A: ASP is not a programming language, but a development environment. ASP provides an environment for executing commands on the server. It uses special symbols () to distinguish between HTML and commands that can be sent to the client only after being translated by the server. It can execute commands such as HTML, Microsoft VBScript, and Microsoft JScript, so it can produce powerful web applications.
2. Question: Can I use PWS to accommodate multiple web sites on a Web server?
A: Only one web site can be accommodated on PWS. To accommodate multiple web sites on the same computer, you need to use Windows NT Server, Windows 2000 Server/professional, and IIS.
3. Question: How to use six built-in ASP objects?
A: ASP provides multiple embedded objects that can be directly accessed and used in commands without being created. These six objects are mainly request objects and response objects) objects, session objects, application objects, server objects, and cookies objects. Other components can be loaded on the server objects of these six objects, this can expand ASP functions.
The object created using server. Createobject. its lifecycle starts when it is created and ends when its webpage program ends. If you want this object to be used across webpages, you can use the session object to record the objects created by server. Createobject.
4. Question: Why is response used. during redirect, the following error occurs: "The title is incorrect. The HTTP title has been written to the client browser. Any changes to the HTTP title must be made before the page content is written "?
A: response. redirect can transfer a webpage to another webpage. The syntax structure is as follows: response. redirect URL. The URL can be a relative address or an absolute address, but it is different in iis4.0 and iis5.0.
An error occurs when iis4.0 transfers a webpage before any data is output to the client browser. Here, the so-called data includes HTML labels, such as <HTML> and <body>, and has been improved in iis5.0. By default, the buffer zone is enabled in iis5.0, such errors are not generated.
There is a buffer attribute in the response object. This attribute can be used to set whether the website will transmit data to the client immediately after processing ASP. However, this attribute must be set before transmitting any data to the client.
For the sake of insurance, no matter which ASP operating platform is used, write <% response. Buffer = true %> at the beginning of the page and set the buffer to enable. This error will not happen.
5. Question: Does the buffer output affect webpage transmission?
A: In a large web page, the first part may have some latency in the browser, but loading the entire web page is faster than without buffering.
6. Question: Can I use the request. querystring set to query the string value when no form is submitted?
A: The request object is used to read data from the browser. In addition to reading the content of form fields, it can also be used to read parameters attached to the URL, no matter how the request string is added to the link address, the request is no different. You can use the request. querystring collection to submit a form using the get method or to query all values of a string following the link of an additional query string.
7. Question: I wrote a lot of comments in the ASP script. Will this affect the server's processing speed of ASP files?
A: It is a good habit to annotate a program. Tested by foreign technical staff, the overall performance of ASP files with too many comments will only drop by 0.1%, that is to say, the performance of the server will not be decreased in actual applications.
8. Question: Do not use <% @ Language = VBScript %>?
A: The <% @ Language = VBScript %> code at the beginning of each ASP file is used to notify the server to write programs using VBScript. However, the default programming language of ASP is VBScript, therefore, you can ignore this code and run it normally. However, if the script language of the program is javascrip, You need to specify the script language in the first line of the program.
9. Question: Do I need to use "option explicit" in every ASP file "?
A: in practical applications, the VBScript variable concept has been vague, allowing direct use of variables without the need for dim to declare variables. However, this is not a good habit and may cause program errors, because a variable may be defined repeatedly. We can use the option explicit statement in the program. When using a variable, we must declare it first. If no declared variable is used, an error occurs during running.
Practice has proved that using "option explicit" in ASP files can minimize program error opportunities and greatly improve overall performance.
10. Question: What are the security measures for running ASP files?
A: ASP provides a good code protection mechanism. All ASP code is executed on the server and only returned to the client for code execution. However, it still does not rule out the deliberate destruction of web servers by malicious people. Therefore, you must pay attention to security issues when writing ASP files.
Although Inc is introduced in ASP, it is recommended that ASP be used as the extension of the cited file. When these codes run on a Web server with poor security mechanisms, you only need to enter the address of the introduced file (Inc is the extension) in the address bar to view the content of the introduced file, this is because on the Web server, if the dynamic Connection Library of a certain type (such as Inc) is not defined, the file is displayed as source code.
In addition, do not place database files inside the website structure. In this way, when attackers obtain the database path, they can easily obtain the database and modify the database content. A good practice is to create a data source name DSN (date source name) for the database, and store information about the connection to the specified data provider in DSN, including: "Physical location of the database, the type of the driver used to access the database. Any other parameters required by the driver used to access the database. "You can directly access the DSN when accessing the database.
11. Question: Which questions should I consider when reviewing the Web Database Management System?
A: When evaluating a web database management system, three problems must be taken into account: multi-user problems; the WEB database established should be relational databases; and database security problems.
12. Question: What is ADO and how does it operate databases?
A: The full name of ADO is ActiveX Data Object (ActiveX Data Object). It is a special set of optimized database access objects. It provides ASP with a complete site database solution, it serves on the server and provides the homepage content containing database information. By executing SQL commands, users can enter, update, and delete information about the site database in the browser screen.
Ado mainly includes three objects: connection, recordset, and command. Their main functions are as follows:
· Connection object: opens or connects to database files;
· Recordset object: access the database content;
· Command object: give action query commands to databases and execute the stored procedures of SQL Server.
13. Question: What is the difference between using A recordset object and a command object to access the database?
A: The recordset object requires the database to transmit all the data. When the data volume is large, network congestion and heavy load on the database server will occur. Therefore, the overall execution efficiency will be reduced.
The command object is used to directly call SQL statements. The operations executed are performed on the database server, which is obviously very efficient. In particular, executing the created storage process on the server can reduce network traffic. In addition, syntax analysis can improve the overall execution efficiency.
14. Question: Do I have to create a connection object for each recordset object?
A: You can use the same connection object for different recordset objects to save resources.
15. Question: What is a database management system (DBMS )?
A: To ensure the security and consistency of the data stored in the database, a group of software must be provided to complete corresponding management tasks. This group of software is the database management system (DBMS for short, DBMS varies with the system, but in general, it should include the following aspects:
Database Description: defines the global logical structure, local logical structure, and other database objects of the database;
Database management functions: including system configuration and management, data access and update management, data integrity management, and data security management;
Database Query and Manipulation: This function includes database retrieval and modification;
Database Maintenance: includes data import and export management, database structure maintenance, data recovery, and performance monitoring.
To improve the development efficiency of database systems, in addition to DBMS, modern database systems also provide a variety of tools to support application development.
16. Question: What are the popular web database management systems?
A: currently, Microsoft SQL Server, Oracle, DB2, and Sybase are popular web database management systems. Access is widely used in small-scale enterprises.
17. Question: What is the difference between using the addnew method of ADO in ASP and directly using the "insert into..." statement? Which method is better?
A: The addnew method of ADO only encapsulates the "insert into" statement. Therefore, when operating a large amount of data, the direct use of SQL statements will greatly speed up data access, because it reduces the "Translation" time of ADO, because the operations executed by SQL statements are directly performed on the database server, especially when the data volume is large, it has significant advantages.
18. Question: Why does an error occur when I use the standard insert record statement insert into books (name, email) values ("kitty", "kitty@263.com") in ASP?
A: Structured Query Language (Structured Query Language) is a data query language developed by IBM in the 1970 s. It has become a standard for relational database query language. An SQL statement is an English-based programming language that can be used to add, manage, and access databases.
Although double quotation marks can be used for strings added to SQL statements, single quotation marks are required in ASP for normal execution. Therefore, insert into books (name, email) values ('Kitty ', 'Kitty @ 263.com') should be written ').
19. Question: What is ActiveX Control? Where can I obtain these ActiveX controls?
A: Microsoft ActiveX controls are reusable software components developed by software providers. In addition to ASP embedded objects, ActiveX controls installed can also be used in ASP, which can save a lot of valuable development time, in fact, many ActiveX controls are embedded in ASP.
Using ActiveX controls, you can quickly add special functions to web applications and development tools. For example, you can use an adrotator object to create an Ad scroll board, use a FileSystemObject object to access files, and use a marquee object to implement scroll text.
Currently, there are more than 1000 commercial ActiveX controls. ActiveX controls can be developed in a variety of programming languages, such as C and C ++, and Microsoft Visual Java Development Environment Microsoft Visual J ++. Once the ActiveX control is developed, designers and developers can regard it as a pre-assembly component for developing customer programs. By using ActiveX controls in this way, users do not need to know how these components are developed. In many cases, they can design webpages or applications without programming themselves.
Currently, there are more than 1000 commercial controls provided by third-party software developers. The Microsoft ActiveX Component Library (ActiveX component Gallery) stores related information and connections, which direct to various ActiveX controls provided by Microsoft and third-party developers. In the Microsoft ActiveX Component Library (ActiveX component Gallery), you can find a list of companies that develop Internet-enhanced ActiveX controls.
20. Question: Why can't I find the value of the start site in the form in the database using the strstartport = (request. Form ("catmenu_0") statement?
A: This is because the starting site value may contain spaces. For example, if the origin site is "Hangzhou", but because of the space, the value obtained by ASP may be "Hangzhou ", however, the database only contains records of "Hangzhou", which cannot be found. The solution is to use the trim function to remove all spaces at both ends of the string. The corresponding statement is:
Strstartport = trim (request. Form ("catmenu_0 "))
21. Question: When the lifecycle of a variable ends in ASP, how many methods can be used to retain the variable content?
A: Any operation that causes the web page to end, for example, when you press the "refresh" button of the browser or close the browser and re-open it, the lifecycle of the variable will end.
If you want to retain the variable content at the end of the web page for the next execution, you can use the application object. For example, you can use the application object to create a counter for counting website visits.
The Session object is the same as the application object. The variable content can be stored at the end of the Web page. However, unlike the application object, each online session object is an independent session object, simply put, all online netusers only share one application object, but each online netuser has its own session object.
The Application Object and Session object can help us record the information on the server, while the cookie object will record the information on the client through the cookies function provided by the browser. Note that cookies are recorded in the browser. Therefore, data access is not as simple as accessing other ASP objects (storing information on the server, the browser can exchange cookies with the server only when the browser starts to browse a webpage of the server and the server has not downloaded any data to the browser.
22. Question: What should I do after the object is used up?
A: After an object is used up, use the close method to release the system resources occupied by the object, and set the object value to "nothing" to release the memory occupied by the object, otherwise, the website may run less efficiently or even crash due to too many objects. The corresponding statement is as follows:
<%
Object. Close
Set object = nothing
%>
23. Question: How can I read HTML form fields in an ASP file?
A: The request object can be used not only to read parameters attached to the URL, but also to read the content of HTML form fields. The syntax structure is as follows:
<Form name = formname method = "get post" Action = "url"> <form>
The method can accept get or post transmission methods. The post method allows transmission of a large amount of data, and the get method attaches the data to be transmitted to the URL, then it is delivered to the server together, so the amount of data transmitted is limited, but the execution efficiency is better than that of the post method.
You can send data to the server using the get or POST method. The method for receiving data using the request object is as follows:
Get: request. querystring ("field name"), which can also be written as request ("field name ")
Post: request. Form ("field name"), which can also be written as request ("field name ")
24. Question: How can I improve the efficiency of using the request set?
A: When a request set is used, it contains a series of searches for related sets, which is much slower than accessing a local variable. Therefore, if you want to use a value in the request set multiple times on the page, you should consider storing it as a local variable.
25. Question: Can I use VBscript or JScript on an ASP page and use the script engine in combination?
A: You can use VBscript or JScript on the ASP page. However, JScript and VBScript cannot be used on the same page at the same time. Because the server must instantiate and try to cache two (rather than one) script engines, which increases the burden on the system to a certain extent. Therefore, in terms of performance, you should not mix multiple script engines on the same page.
26. Problem: When an ASP file is created and syntactically compliant, enter the following address in the browser or open the browser through the resource manager: C:/inetpub/wwwroot/. ASP, there will be an error that cannot be run, and the prompt is that the permission is incorrect or the file cannot be accessed. Why can't asp files run normally?
A: This is because the ASP file requires that the site have the "execute (SCRIPT)" attribute first, and then enter the address in URL format instead of DOS format, we need to install and start the Web Service Platform on the computer, and ensure that ASP files are stored in the virtual directory of the web server, you can browse through the HTTP format, enter in the address bar of the browser: http: //; Web site name (or site IP address)/asp File Name ". Press enter to view the result of ASP file execution on the server in the browser.
27. Question: What is ASP. NET? What is the relationship between ASP and ASP?
A: Active Server Pages (Asp, Active Server Pages) is a simple programming environment where HTML, script language, and a few components can be used together to create internet applications on the server;
ASP. NET is a powerful programming environment launched by Microsoft. You can use C # and other advanced languages and scripting languages, HTML, XML, and XSL to create network-based applications. ASP. NET regards C # As an object-oriented language. In many aspects, C # will become a language similar to Microsoft and Java. C # is one of the most important functions in ASP. NET development. Microsoft will develop C # into a strong competitor of Java. This is also an important part of the Microsoft. NET Framework. I think C # is the main tool for Microsoft to beat its opponent in the programming language field.
ASP. net is superior to ASP programs in terms of object-oriented, database connection, and large site applications. asp. net also provides more new features, such as built-in object caching and PAGE result caching; built-in XML support, which can be used for simple processing of XML datasets; server Control provides more interactive systems.
ASP. NET is still completely locked in Microsoft's operating system. To realize ASP. NET's potential, you need to use C # Or VB.net. These two languages will become the core scripting language of ASP. NET standards.