ASP depth revealed (below)

xiaoxiao2021-03-06  62

Fourth, the development and use of ASP components: 1. Component's characteristics? l Addition: n call is convenient, save code n security high N support transaction processing, multi-component combination N run speed fast n upgrade, modifying the component does not need to modify the page, so the spreadability L Disadvantages: N development and commissioning difficult 2. How to develop VB? (1). Open VB >> New Project >> ActiveX DLL (2). Modify the project name as course (3) 3) The name of the modification class module is conn_db ⑷. Project >> References, Quote COM Service Type Library and Microsoft Active Server Pages Object Library.

. Modify the class code as follows: 'database connection is established and output database fields Dim Response As ResponseDim Request As RequestDim Server As ServerDim Application As ApplicationDim Session As Session Private Sub Class_Initialize () Dim objContext As ObjectContextSet objContext = GetObjectContext () Set Response = objContext ( "Response ") SET Request = ObjContext (" Request ") SET Server = Objcontext (" Server ") set application = objcontext (" Application ") set session = objcontext (" session ") End sub sub conn_db () set conn = creteObject (" Adodb.connection ") Conn.open" course_dsn "," course_user "," course_password "set = createObject (" adoDb.recordset ") rs.open" Select * from user_info ", conn, 1, 1 if xi r rdcount> 0 Thenfor I = 1 to Rs.RecordCountResponse.write "
" & = "
" if xi = nothingconn.closset rs = nothingconn.closeset rs = nothingconn.closeset . Add a new class of CUTSTR ⑺. The modified class code is as follows: 'Intercept string function cutstr (str, length) ife (str)> length lifeStr = Left (str, length) & "..." elsecutstr = strend ingnd function ⑻. File >> Save. File >> Make Course.dll 3. Registration Components: MTS and Regsvr32.exe have two ways of registration components: MTS and use regsvr32.exe. MTS is worth recommending because it has the following advantages: n Dynamic unload balancing, improves the upgradeability of components and component-based applications. n The ability to publish and submit events and queue components, making it easier to combine multiple components. To make the components have the characteristics of MTS, you must do less changes to the components. When developing under NT and 98, Microsoft Transaction Server Type Library must be referenced in the project, developed under Windows 2000, must reference COM Service Type Library. (1). Regsvr32 Registration: Regsvr32.exe is an executable of the SYSTEM32, which reads component information into the registry so that ASP calls.

Use the command line to enter the directory where the component DLL file is located, execute "Regsvr32 DLL_FILE_NAME". Running regedit, find Course.Conn_DB items and Course.cutstr items under HKEY_CLASSES_ROOT, indicating that the component is registered successfully. (2). Use MTS registration: 1. Start >> Program >> Management Tools >> Component Services 2. Expand the directory to the following status: 3. According to the wizard, next, until the following dialog box, click "Create an empty application": 4. In the next dialog, the application is called "course", the other default until it is completed. Expand the courte application, right, create a new component 6. Follow the prompts, continue, when the following dialog box appears, select "Import the registered component" 7. Choose the components we develop, the next step until it is completed. At this time, there can be more than two components under Course applications: 4. Calling component asp_use_com.asp <% 'ASP calls COM components set cutstr_obj = server.createObject ("Course.cutstr") response.write cutstr_obj.cutstr ("Abcdefghijk", 3) & "
" set cutstr_obj = Nothing set conn_obj = server.createObject ("course.conn_db") conn_obj.conn_db () set conn_obj = Nothing%> Effect: ABC ... AHYI Tuth Description Call success. 5. Uninstalling components (1). Use the registered components registered using the REGSVR32, uninstall: Note: First enter the directory where the component DLL is located, then use "Regsvr32 -u DLL_FILE_NAME" uninstall; uninstall IIS. (2). Using MTS registered components, first remove the corresponding application in "Component Services", then perform step (1) to completely uninstall the components. 6. DLL component storage location and permissions set (1). We only need to copy the compiled DLL file, and other files don't have to be processed (2). To put the DLL outside the Web site, such as the System32 directory, prevent being downloaded (3). The DLL file is set to System Read, the Internet user traverses folder / run file ⑷. DLL removes all permissions in IIS, such as reading, scripting voluntary access, etc., ensuring security of the DLL file.

7. Others How to use ASP objects in the component to easily transplant the ASP code to COM components? V. IIS Optimization Configuration 1. Web site tab: IP, port, virtual host, connection, log 2. ISAPI Filter: Add PHP and JSP Support 3. Home Licat Configuration Tab: I IS Permissions Settings (Combined with File Right), Permission, Application Protection, Mapping, Buffer, Parent Path, Error Information 4. Other tab: Custom Errors, HTTP Head, Directory Security, Document 5. The benefits and disadvantages of document compression is six, others 1. Send an email (Jmail; MS SMTP) uses Microsoft SMTP to send email (1). Install Microsoft SMTP Service (2). Set Microsoft SMTP Service (3). Code portions: mail_smtp.asp <% sub sendmail (fromwho, towho, subject, body) dim mymailset mymail = server.createobject ( "cdonts.newmail") mymail.from = fromwhomymail.to = towhomymail.subject = subjectmymail.body = bodymymail .Sendset mymail = nothingend sub%> This subroutine accepts four parameters corresponding to each of the following. L message sender's Email address L mail recipor's Email address L mail topic L mail content usage method: <% fromwho = ... Towho = ... casent = ... body = ... if Towho <> "" Tensendmail fromWho, Towho, Subject, BodyEnd IF%> Use Jmail to send Email slightly, interested, can be discussed with me, Jmail this software I also have.

2. Unzip the ZIP file (WScript.Shell and Winzip Command Line; Java Components) (1). Install WinZip 8.1 or more (2). Install Winzip Command LINE 3 (3). Set the files of the working directory to Internet users to read, write, and modify. Code section: unzip_a_zipfile.asp <% 'Use shell object starter' zip_path is the path to specific ZIP files, such as c: /test.zip'path is the path of the file after the decompression file 'OON is the command line parameter set wshshell = server. createobject ( "wscript.shell") issuccess = wshshell.run ( "wzunzip -ond" & zip_path & "" & path, 1, true) 'delete zip file set myfileobject = server.createobject ( "scripting.filesystemobject") myfileobject.deletefile zip_path' Judging whether it is successful to continue if Issuccess = 0 Then 'success ... Else' failed ... END IF%> 3. Operation XML file This time AC time is limited, and there is a time to discuss 4. Document Upload (1). Installation file upload component ASP fileup (support multi-file upload, file type and size judgment, file upload change after renovation, etc.) (2). Heat IIS to enable upload components to take effect (3). Set the files for the upload directory to read, write, and modify the Internet. Code section UPLOAD_FILE.htm