Using ActiveX dll vs. ASP include for functions.

I'm just learning how to create ActiveX DLL's for use in ASP pages.

My question is:
Is it better to create all of my functions in a DLL
vs. using Include statements to load a page of functions.

I understand it's much easier to change the ASP page if my code needs
to change, but I am more interested in speed and performance.

For example, is it a bad idea to put a simple function such as:

Public Function GetDomain(strEmailAddr As String) As String
  Dim sFnd() As String
  sFnd = Split(strEmailAddr, "@")
  GetDomain = sFnd(1)
End Function

in the DLL or should I just leave it as ASP?

What about text that is never changed (but required in the application), I had the idea of using a public property get to return the text?
LVL 4
Frog357Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
PaulHewsConnect With a Mentor Commented:
>>but I am more interested in speed and performance.<<

There is some overhead involved in making a call to a DLL, so from a performance point of view, it is better to use it for "heavier" calls.  When I've used DLLs, I pass the parameters received by the ASP page and process and output with Response object in the DLL.  Optimized compiled code will run quickly in a DLL as compared to the interpreted VBScript code in your ASP page.

>What about text that is never changed (but required in the application), I had the idea of using a public property get to return the text? <

I don't think there is any advantage to storing constant values in the DLL.  There are many advantages to doing all processing and output in the DLL, however.
0
 
Frog357Author Commented:
Can you provide me with a few examples on using the standard ASP objects in the DLL?  Or a link would be great!

I would like to access:
Request.Form
Response.Redirect
Session.Abandon

I increased points to 100.

My production server is a Pentium Pro 200 so I've set the option to Favor PPro CPU, I'm trying to get as much from this box as possible!
0
 
EDDYKTCommented:
If you don't have to hide your source code, you don't have to call dll, put everything in ASP page.

It is lot more easy to debug your problem.
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
Richie_SimonettiIT OperationsCommented:
Also, you wouldn't have problem with version compatibility and updating existing code is an easy process.
0
 
PaulHewsCommented:
Add a reference to the Microsoft Active Server Pages Object.  Then you can use the standard ASP objects either by passing them into the DLL as a parameter to a function call. Otherwise, you can create them using ObjectContext as per this MS article:

http://support.microsoft.com/default.aspx?scid=KB;en-us;q238274
0
 
rzweifelCommented:
Here is a walkthrough that should get you started on referencing the intrinsic ASP objects from VB:

http://www.devguru.com/features/tutorials/CreateActiveX/tutCreateActiveX_VB.html

I disagree with EDDYKT. I think VB code is a lot easier to debug than ASP code.
0
 
PaulHewsCommented:
Eddy, I find it easier to write code and debug in VB.  Updating existing code and maintaining compatibility require work and planning, but this is also true of coding an entire application in VBScript; I'm not convinced my approach is the more difficult.  

Also of note, one has to stop and restart the web server for each compile, this can cause a problem if your production server has to have zero downtime.
0
 
rzweifelCommented:
If you're "interested in speed and performance" the best way to go might be ASP.NET. Also, you could update dlls without shutting down IIS.
0
 
Frog357Author Commented:
Thanks PaulHews,
The information provided is enough to help me complete my project.  I am very familiar with optimizing VB code and I've always hated explicit variants in VBScript, I guess I'll recreate everything and see how it flies ;)  I am still planning on holding constants in the DLL just to keep the ASP pages clean.  Plus the ability to optimize the DLL for use with a Pentium Pro makes me think I might be able to squeeze a little more from my work!

Sometimes people who teach themselves get tired and thats when EE comes to save the day!
0
 
PaulHewsCommented:
>>I am still planning on holding constants in the DLL just to keep the ASP pages clean.<<

If that's an issue, you can also do a simple include to include the contents of a text file.

<!--#include file="myfile.txt"-->

This inserts the contents of the text file into the HTML stream, the same as if it was entered into the file instead of the include directive.  You can include asp code and functions in the same way.
0
 
Frog357Author Commented:
That is what I was currently using, but I'm planning on switching a lot of code into a dll for reusability and security.
0
 
PaulHewsCommented:
Yeah, unfortunately, you can't do:
Response.Write "<!--#include file='myfile.txt'-->"
But string and file manipulation is very easy within VB so it's easy to emulate.
0
All Courses

From novice to tech pro — start learning today.