Recommended: Use Asp to hide the file path to realize the anti-theft chain If we know the actual path of a static file such as: http://www.xx.com/download/51windows.pdf, if the server does not have special restrictions, we can download it effortlessly! When the website provides 51windows.pdf download, how
Calculate the size of the character
len() is a character that counts one, and a letter that counts one.
lenb() is both letters and characters
| The following is the quoted content: function getlen(str) n=0 for i=1 to len(str) charasc=asc(mid(str,i,1)) if ((charasc<127) and (charasc>=32)) then n=n 1 else n=n 2 next getlen=n end function |
1. How to use Asp to determine the virtual physical path of your website
Answer: Use the Mappath method
| The following is the quoted content: < p align=center >< font size=4 face=Arial >< b > The Physical path to this virtual website is: < /b >< /font > < font color=#FF0000 size=6 face=Arial > < %= Server.MapPath(/)% > < /font >< /p > |
2. How do I know the browser used by the user?
Answer: Use the Request object method
| The following is the quoted content: strBrowser=Request.ServerVariables(HTTP_USER_AGENT) If Instr(strBrowser,MSIE) < > 0 Then Response.redirect(ForMSIEOnly.htm) Else Response.redirect(ForAll.htm) End If |
3. How to calculate the average number of repeated visits every day
Answer: Solution
| The following is the quoted content: < % startdate=DateDiff(d,Now,01/01/1990) if strdate< 0 then startdate=startdate*-1 avgvpd=Int((usercnt)/startdate) % > |
Show results
| The following is the quoted content: < %response.write(avgvpd) % > that is it.this page have been viewed since November 10,1998 |
4. How to display random images
| The following is the quoted content: < % dim p,ppic,dpic ppic=12 randomize p=Int((ppic*rnd) 1) dpic=graphix/randompics/&p&.gif % > show < img src=< %=dpic% > > |
5. How to return to the previous page
| The following is the quoted content: Answer: < a href=< %=request.serverVariables(Http_REFERER)%> >preivous page< /a > |
Or use a picture such as: < img src=arrowback.gif alt=< %=request.
serverVariables(HTTP_REFERER)% > >
6. How to determine the other party’s IP address
Answer: < %=Request.serverVariables(REMOTE_ADDR)% >
7. How to link to a picture
| The following is the quoted content: Answer: < % @Languages=vbscript %> < % response.expires=0 strimagename=graphix/errors/erroriamge.gif response.redirect(strimagename) % > |
8. Force password input dialog box
Answer: Put this sentence at the beginning of the page
| The following is the quoted content: < % response.status=401 not Authorized response.end % > |
9. How to pass variables from one page to another
Answer: Use the HIDDEN type to pass variables
| The following is the quoted content: < % 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 > |
10. Why do I use msgbox in the asp program? The program error says there is no permission
Answer: Since asp is run by the server, if a dialog box can be displayed on the server, you have to wait until someone presses OK before your program can continue to be executed. Generally, there will be no one on the server, so Microsoft has to ban this function and tell you randomly (:) Haha) that there is no permission. However, ASP and client scripts can display a dialog box.
| The following is the quoted content: as follows: < % yourVar=Test dialog%> < % script language='javascript' > alert(< %=yourvar% >) < /script > |
11. Is there a way to protect your source code so that you won't see it
A: You can download a Microsoft Windows Script Encoder, which can encrypt asp scripts and client javascript/vbscript scripts. . . However, after the client is encrypted, only ie5 can be executed. After the server is encrypted, only if script engine 5 is installed on the server (you can install one ie5) can be executed.
12. How can I transfer query string from one asp file to another?
Answer: The former document is added to the next sentence:
| The following is the quoted content: Response.Redirect(second.asp? & Request. ServerVariables(QUERY_STRING)) |
13. The global.asa file always doesn't work?
Answer: Only when the web directory is set to web application, global.asa is valid, and global.asa is valid in the root directory of a web application. IIS4 can use Internet Service Manager to set application settings How can the htm file execute script code like an asp file?
14. How can the htm file be able to execute script code like an asp file?
Answer: Internet Services Manager -> Select default web site -> Right mouse button -> Menu properties -> Home directory -> Application Settings -> Click button configuration -> App mapping -> Click button Add -> executable browser Select /WINNT/SYSTEM32/INETSRV/ASP.DLL EXTENSION Enter htm method excclusions Enter PUT.DELETE All confirm. However, it is worth noting that in this way, the efficiency will be reduced.
15. How to register components
Answer: There are two ways.
The first method: manually register DLL This method is used from IIs 3.0 to IIs 4.0 and other Web Servers. It requires you to execute it in the command line, enter the directory containing the DLL, and enter: regsvr32 component_name.dll For example, c:/temp/regsvr32 AspEmail.dll It will register the specific information of the dll into the registry in the server. Then this component can be used on the server, but this method has a flaw. After registering a component using this method, the component must set the corresponding anonymous account with NT to have permission to execute this dll. In particular, some components need to read the registry, so the method of registering components is just to use if there is no MTS on the server. To unregister this dll, use: regsvr32 /u aspobject.dll example c:/temp/regsvr32 /uaneiodbc.dll
The second method: Using MTS (Microsoft Transaction Server) MTS is a new feature of IIS 4, but it provides a huge improvement. MTS allows you to specify that only privileged users can access components, greatly improving security settings on the website server. The steps to register a component on MTS are as follows:
1) Open the IIS Management Console.
2) Expand transaction server, right-click pkgs installed and select newpackage.
3) Click create an empty package.
4) Name the package.
5) Specify the administrator account or use interactive (if the server often logs in with administrator).
6) Now use right-click the expanded components below the package you just created. Select new then component.
7) Select install new component [b].
8) Find your .dll file and select next to finish.
To delete this object, just select its icon and select delete.
Note: Pay special attention to the second method, which is the best way to debug the components you write yourself without having to restart the machine every time.
16. Connect ASP to Access database:
| The following is the quoted content: <%@ language=VBscript%> <% dim conn,mdbfile mdbfile=server.mappath(database name.mdb) set conn=server.createobject(adodb.connection) conn.open driver={microsoft access driver (*.mdb)};uid=admin;pwd=number Database password;dbq=&mdbfile %> |
17. Connect ASP to SQL database:
| The following is the quoted content: <%@ language=VBscript%> <% dim conn set conn=server.createobject(ADODB.connection) con.open PROVIDER=SQLOLEDB;DATA SOURCE=SQL server name or IP address; UID=sa;PWD=database password;DATABASE=database name %> |
Create a record set object:
| The following is the quoted content: set rs=server.createobject(adodb.recordset) rs.open SQL statement,conn,3,2 |
18. Common SQL command usage methods:
(1) Data record filtering:
sql=select * from data table where field name=field value order by field name[desc]
sql=select * from data table where field name like '%field value %' order by field name
[desc]
sql=select top 10 * from data table where field name order by field name [desc]
sql=select * from data table where field name in ('value 1','value 2','value 3')
sql=select * from data table where field name between value 1 and value 2
(2) Update data records:
sql=update data table set field name=field value where conditional expression
sql=update data table set Field 1=value 1, Field 2=value 2... Field n=value n where conditional expression
Mode
(3) Delete data records:
sql=delete from data table where conditional expression
sql=delete from data table (delete all records in the data table)
(4) Add data records:
sql=insert into data table (field 1, field 2, field 3…) valuess (value 1, value 2, value 3…)
sql=insert into target data table select * from source data table (add the record of the source data table to the target data table)
(5) Data record statistics function:
AVG (field name) to obtain an average value of a table column
COUNT(*|field name) Statistics on the number of data rows or statistics on the number of data rows with values in a certain column
MAX (field name) Get the maximum value of a table column
MIN (field name) Get the minimum value of a table column
SUM (field name) adds the value of the data column
Reference the above function method:
| The following is the quoted content: sql=select sum(field name) as alias from data table where conditional expression set rs=conn.excute(sql) |
Use rs (alias) to get the statistics, and other functions are used the same as above.
(5) Establishment and deletion of data tables:
CREATE TABLE Data table name (field 1 type 1 (length), field 2 type 2 (length)…)
Example: CREATE TABLE tab01(name varchar(50), datetime default now())
DROP TABLE Data table name (permanently delete a data table)
19. Methods for recording set objects:
| The following is the quoted content: rs.movenext Moves the record pointer down one line from the current position rs.moveprevious Moves the record pointer up one line from the current position rs.movefirst Moves the record pointer to the first row of the data table rs.movelast Moves the record pointer to the last row of the data table rs.absoluteposition=N Move the record pointer to row N of the data table rs.absolutepage=N Move the record pointer to the first line of page N rs.pagesize=N Set each page to N records rs.pagecount returns the total number of pages according to the settings of pagesize rs.recordcount Returns the total number of records rs.bof Returns whether the record pointer exceeds the head of the data table. True means yes, false is no rs.eof Returns whether the record pointer exceeds the end of the data table, true means yes, false is no rs.delete deletes the current record, but the record pointer does not move downwards rs.addnew Add record to the end of the data table rs.update Update data table records |
20. Recordset object method
Open method
recordset.Open Source,ActiveConnection,CursorType,LockType,Options
Source
The Recordset object can be connected to the Command object through the Source property. The Source parameter can be a Command object name, a SQL command, a specified data table name, or a StoredProcedure. If this parameter is omitted, the system uses the Source property of the Recordset object.
ActiveConnection
The Recordset object can be connected to the Connection object through the ActiveConnection property. The ActiveConnection here can be a Connection object or a string parameter containing database connection information (ConnectionString).
CursorType
The CursorType parameter of the Open method of the Recordset object indicates what cursor type to start the data, including adOpenForwardOnly, adOpenKeyset, adOpenDynamic and adOpenStatic, which are described as follows:
| The following is the quoted content: -------------------------------------------------------------- Constant constant value description ------------------------------------------------------------- adOpenForwardOnly 0 Default value, start a cursor that can only move forward (Forward) Only). adOpenKeyset 1 Starts a Keyset type cursor. adOpenDynamic 2 Start a Dynamic type cursor. adOpenStatic 3 Starts a Static type cursor. ------------------------------------------------------------- |
The above cursor types will directly affect all properties and methods of the Recordset object. The following list explains the difference between them.
| The following is the quoted content: ------------------------------------------------------------- Recordset property adOpenForwardOnly adOpenKeyset adOpenDynamic adOpenStatic ------------------------------------------------------------- AbsolutePage does not support readable, writeable, readable, writeable AbsolutePosition does not support readable, writeable, readable, writeable ActiveConnection Readable, writeable, readable, writeable, readable, writeable, readable, writeable BOF Read-only Read-only Read-only Read-only Bookmark does not support readable, writeable, readable, writeable CacheSize Readable, Writeable, Readable, Writeable, Readable, Writeable CursorLocation Readable, writeable, readable, writeable, readable, writeable, readable, writeable CursorType Readable, writeable, readable, writeable, readable, writeable, readable, writeable EditMode Read-only Read-only Read-only Read-only EOF Read-only Read-only Read-only Read-only Filter readable, writeable, readable, writeable, readable, writeable, readable, writeable LockType Readable, writeable, readable, writeable, readable, writeable, readable, writeable MarshalOptions Readable, Writable, Readable, Writable, Readable, Writable MaxRecords Readable, Writable, Readable, Writable, Readable, Writable PageCount does not support read-only read-only PageSize Readable, writeable, readable, writeable, readable, writeable, readable, writeable RecordCount does not support read-only read-only Source Readable, writeable, readable, writeable, readable, writeable, readable, writeable State Read-only Read-only Read-only Read-only Status Read-only Read-only Read-only Read-only AddNew Support Support Support Support CancelBatch Support Support Support Support CancelUpdate Support Support Support Support Clone does not support it or not Close Support Support Support Support Delete Support Support Support Support GetRows Support Support Support Move does not support support support support MoveFirst Support Support Support Support MoveLast does not support support support support MoveNext Support Support Support Support MovePrevious Not supported Support Support Support Support NextRecordset Support Support Support Support Open Support Support Support Support Requery Support Support Support Support Resync does not support support support support Supports Support Support Update Support Support Support Support UpdateBatch Support Support Support Support -------------------------------------------------------------- |
The NextRecordset method is not applicable to Microsoft Access databases.
LockType
The LockType parameter of the Open method of the Recordset object indicates the Lock type to be adopted. If this parameter is ignored, the system will use the LockType property of the Recordset object as the preset value. The LockType parameters include adLockReadOnly, adLockPrssimistic, adLockOptimistic and adLockBatchOptimistic, etc., and are described as follows:
| The following is the quoted content: ------------------------------------------------------------- Constant constant value description -------------------------------------------------------------- |
adLockReadOnly 1 Default value, Recordset object is started in read-only mode, and methods such as AddNew, Update, and Delete cannot be run. adLockPrssimistic 2 When the data source is being updated, the system temporarily locks other users' actions to maintain data consistency.
adLockOptimistic 3 When the data source is being updated, the system will not lock other users' actions. Other users can add, delete and modify the data.
adLockBatchOptimistic 4 When the data source is being updated, other users must change the CursorLocation property to adUdeClientBatch to add, delete and modify the data.
Share: Introduction to the basics of humanities ASP development What is ASP? ASP is the abbreviation of Active Server Pages, which is the active server page. ASP files have .asp as the extension. What's special about it is that all markup languages that can be used in Html files can be used in ASP files, and ASP files