| | Submitted on: 7/14/2000 7:52:32 AM
By: Bernhard "Bard" Doebler
Level: Intermediate User Rating: Unrated Compatibility:ASP (Active Server Pages)
Users have accessed this article 6190 times. | (About the author) |
| | In this article I shortly want to explain how to move Output from Response.Write in an ASP-Script to a COM-component what my be faster.
If you don't have your own webserver than you hardly have a chance to use self-developed components like this since you're in many, many cases not allowed to register your own components for security reasons.
Sorry. | |
|
Terms of Agreement:
By using this article, you agree to the following terms...
1) You may use
this article in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
2) You MAY NOT redistribute this article (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.
3) You may link to this article from another website, but ONLY if it is not wrapped in a frame.
4) You will abide by any additional copyright restrictions which the author may have placed in the article or article's description. | The code is relatively simple. You start Visual Basic (I thought the code does more belong in this forum than the VB forum), create a new ActiveX-DLL, name your project and the by default created class as you like and insert the following code.
Public Function Ausgeb(strAusgeb As String, rspResponse As Response) As Boolean
rspResponse.Write strAusgeb
Ausgeb = True
End Function
Public Function AusgebLn(strAusgeb As String, rspResponse As Response) As Boolean
rspResponse.Write strAusgeb & vbCrLf
AusgebLn = True
End Function
Then you save it and compile it to a DLL.
You then start Visual Interdev or your favourite ASP-editor and insert the following lines between the body-tags in script tags I at the moment don't know how to show here.
set a=Server.CreateObject
("ASPTest.ResponseTest")
a.AusgebLn "Hallo",Response
a.Ausgeb "Hallo",Response
set a=nothing
I named my project ASPTest and the Class ResponseTest. You have to change it to your project's and class' names.
You save this file in your WWWRoot or a subfolder.
After you've registered the ActiveX-DLL with Regsvr32 you can call the ASP-File via your localhost or the webserver you saved it on.
If you then throw a look at the sourcecode of the output you'll see the word "Hallo" twice in two lines.
I'm sure you've guessed what the two Methods of the class do and where the differences are.
I'm at the moment not quite sure if it's faster than Response.Write but with longer text and a properly set up Transaction Server it surely can accelerate your web-applications.
Giving the Response-object by reference is much easier than finding it out using the GetObjectContext-method of a MTS-object.
If you change the Sourcecode of the DLL (e.g. if you enlarge the functionality) and get errors recompiling you have to stop the webserver, shutdown the Transaction Server and restart again.
I do this using a batch file.
@echo off
NET STOP iisadmin /y
MTXSTOP
NET START W3SVC
I hope this article helpes you to understand how to develop ActiveX-DLLs for server side use. | |
|
Report Bad Submission |
|
|
Your Vote! |
See Voting Log |
|
Other User Comments |
7/17/2000 11:07:26 PM:Mack 10 Great job!
Also, there is a great
new programming site at dev-center.com.
Could you please submit your code there
too?
|
7/17/2000 11:08:10 PM:Mack 10 http://www.dev-center.com
|
8/24/2000 3:37:35 AM:Dr.Dré How do i use regsvr32 at the server of
my provider.
|
8/24/2000 4:35:58 AM:Bard Hi,
on Thursday August the 24th I've
added the tip you with many providers
can't register your own
components.
Thanks for taking notice
of this code.
|
1/17/2001 4:33:29 PM:Slacquer If you were to set binary compatibility
then you wouldnt have the prob with
haveing to RESET your server.
Do
this..
Compile the DLl
then make a
BAK of it say MYDLL.DLL.BAK
Then Use
the BAK as the component for the
Bianary compatibility. The reason for
this is that when you compile VB will
let you know if your not going to be
backwards compatible.
I hope this
helps a bit as im a VB'r not an ASP guy
(just started looking at this stuff
today)
What you have Explained here is
nothing diffrent then say a "PLUGIN"
app using another app. Its actually
quite easy in C or VB But im guessing
its tough with ASP?
|
1/18/2001 4:07:22 AM:Bard himself It's true, it's true. Your totally
right. The component is written and
compiled using VB and using binary
compatibility is a good thing. I
haven't tried yet but I will do. Thanks
for that hint.
|
6/13/2001 1:10:42 PM:Lewis Moten Hmm... You could always include the
scripting context rather then passing
the Response Object to the subroutine.
But you may run into problems with
marshalling when you bring COM+ into
the picture.
|
|
Add Your Feedback! |
Note:Not only will your feedback be posted, but an email will be sent to the code's author in your name.
NOTICE: The author of this article has been kind enough to share it with you. If you have a criticism, please state it politely or it will be deleted.
For feedback not related to this particular article, please click here. |
|