Although ASP. NET Code The Encapsulation Scheme is good and can completely replace ASP, but I am used to ASP, and I don't want to use it for some small projects. net is a big thing, because the computer performance is not keeping up with, so there are still various problems of ASP encapsulation, after many experiments, write some experiences in the process of converting to DLL:
1. Differences between code and DLL
Add the following section before DLL code to reference the five ASP objects:
<textarea style="WIDTH: 576px; HEIGHT: 233px" rows="10" cols="63">Private context as scriptingcontext <br/> private application as application <br/> private response as response <br/> private request as request <br/> private session as session <br/> private server as server </P> <p> Public sub onstartpage (passedscriptcontext as scriptingcontext) <br/> set context = passedscriptcontext 'asp runtime environment object <br/> Set Application = context. application 'asp five objects <br/> Set Request = context. request <br/> set response = context. response <br/> set Server = context. server <br/> set session = context. session <br/> end sub</textarea> To reference Microsoft Active Server Pages Objects library
If the DLL also encapsulates connections and recordset, the DLL project can be written in the original ASP database, or by referencing the following parts:<textarea style="WIDTH: 576px; HEIGHT: 25px" rows="1" cols="63">Microsoft ActiveX Data Objects 2.7 Library</textarea>
At the same time, the original ASPProgramThe server. Createobject ("ADODB. Connection") in is changed to the following format and added to the Code header.
Public conn as new ADODB. Connection <br/> Public RS as new ADODB. recordset
In addition, when the program ends, remember to close the connection to avoid occupying system resources and affecting server operation.
Set rs = nothing <br/> Rs. Close <br/> set conn = nothing "sets the connection to null to release the resources it occupies. <Br/> conn close closes the connection (no resources occupied by the connection are released)
3. dll debugging
In the conventional approach, you often need to restart IIS. This is annoying. The simplest way is to write a bat command and save it as SSS. bat, put on the desktop, run once before each DLL modification, and then generate the DLL in VB6, you can run the program, no need to register the DLL again, why? I do not know:
Regsvr32 E: \ VB \ vbdll \ My. dll-u <br/> net stop "World Wide Web Publishing Service" <br/> Net start "World Wide Web Publishing Service"4. Change ASP script writing habits
Generally, I will first write a common ASP program and convert it to a DLL only when it is delivered to the client. At this time, pay attention to dividing the program code and HTML into two obvious parts during ASP code writing, it takes a lot of effort to modify and organize the conversion.
5. Others... (Think of writing again)