Using VB to write pure ASP program

Source: Internet
Author: User
Program a few days ago, eldest brother said to me, the use of ASP really troublesome, compiling environment is really bad, he is always in VB to write good debugging code and then in the code pasted to ASP
program, and to that end, I propose a solution here. Using VB to replace all the objects of ASP, in VB to write a pure ASP program.

We should all know, in fact, many of the ASP components are written using VB, but let everyone feel very inconvenient is how to use the ASP inherent several
components, such as response,request,application,session, and so on, if I can use these components directly in VB, then I can
Enough to directly use VB to write ASP application procedures.

The following are detailed steps:

1. Create a new ActiveX DLL in VB. I omitted the process of naming items and classes.

2. Now you need to refer to two DLLs in VB.

The first is the DLL that references the ASP engine.

Select the Project\references command from the menu to refer to ' Microsoft Active Server Pages Object Library '.

If you don't find it, you can find this Asp.dll file%systemdirectory%/system32/inetsvr directory in the following directory

Click the button ' Browse ... ' to import this dynamic connection library

The second is to refer to a Microsoft Transaction Server (MTS) object. Select the same command, reference

' Microsoft Transaction Server Type Library '.

If you don't find it, you can find this Mtxas.dll file in the following directory

%systemdirectory%/system32/mts/3. Okay, all the preparation is done, here's how to write the code, I think we all can see
Of

This is the code for the class file:

Option Explicit

Dim M_objresponse as Response

Dim M_objrequest as Request

Dim M_objserver as Server

Dim M_objapplication as Application

Dim M_objsession as session

Private Sub Class_Initialize ()

Dim Objcontext as ObjectContext

Set objcontext = GetObjectContext ()

Set m_objresponse = objcontext ("Response")

Set m_objrequest = objcontext ("Request")

Set m_objserver = objcontext ("Server")

Set m_objapplication = objcontext ("Application")

Set m_objsession = objcontext ("session")

End Sub

Public Sub asptest ()

M_objresponse.write "Farewell to WordPad, the use of VB environment to write ASP program!" "

End Sub

Paste the above code copy into your program, and then compile the project into a DLL. Last use

regsvr32 Componentname.dll Registers this DLL in IIS.

Here's how to use this component in an ASP file:

<%

Set objtest = Server.CreateObject ("Yourprjname.asptest")

Objtest.asptest

Set objtest = Nothing

%>

Well, hope my method can solve eldest brother's distress, hehe.



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.