Home arrow ASP arrow Page 2 - Top Tips -- Developing Components for ASP

Top Tips -- Developing Components for ASP

ASP components are powerful tools and can add serious power to a web site. In this article Sam shares his tips for developing components for ASP with us.

Author Info:
By: Sam Huggill
Rating: 5 stars5 stars5 stars5 stars5 stars / 13
December 05, 2002
  1. · Top Tips -- Developing Components for ASP
  2. · A Little Background

print this article

Top Tips -- Developing Components for ASP - A Little Background
(Page 2 of 2 )

The first thing Iíll do will be to give you a little background on the topic of ASP and components. ASP seems to be coming into its own right now, and many people are starting to migrate to the Windows platform to support this new technology. One of its key advantages is that you can write components in a language such as VB and use them through ASP.

A typical component might interact with a SQL Server database handling information about customers or their orders. Whatever the task, it would appear that there are a wide variety of technologies available to help you out here.

For starters, Microsoft Transaction Server enables you to pool a small amount of resources that can be shared amongst many users. You can host a VB DLL within MTS, and share SQL Server connections as required.

Next, Internet Information Server, Microsoftís free web server product allows you to run your DLLs out of the IIS process, meaning that you DLL can crash but not take down the whole web server as well. IIS 5 (in Windows 2000) now supports a multitude of component pooling and looks very handy.

OK Ė so whatís useful about a component? Well, it encapsulates all the code for a specific function into one part Ė making bug fixing and updating much easier. You can host this DLL on another machine if necessary, using DCOM to communicate with it as well as hosting it in Microsoft Transaction Server. But the real benefits of using a component come about when writing it. Using a language we all know well, VB, in an excellent design environment makes things a lot easier.

Over the next few pages I will give you a stack of tips to help you develop, debug and test such components.

Developing and Debugging
If you ever used Visual Interdev, youíll probably think that itís great for writing ASP. IntelliSense object models popup even for custom components and the debugging tools look almost as good as the ones in VB. The reality of this is far from great. Every time you open a page that makes an instance of your DLL, Visual Interdev loads that DLL into memory to get its object model. So if you want to recompile your DLL you have to close down your page.

Thatís not too much of a problem, but when you actually run the page in your browser it appears that however much you try you canít get ASP to release your DLL! This either means a complete reboot or a stop and start of IIS. Windows 2000 adds a well needed restart feature but for those of you running IIS 4 hereís a little DOS batch file that will take care of restarting IIS:

@echo off
NET STOP iisadmin /y

Simply run that each time and IIS will be restarted, flushing all components out of memory.

The next problem that I came up against was passing parameters into my DLL. As VBScript does not support variable types, every variables is a Variant. This cause lots of problems when you pass it as a parameter to a DLL which expects a string. Instead of converting it to a string (which would be expected) it throws up a Type Mismatch error Ė so ensure all parameters coming in are declared as Variants. This is not the case when you return, so you donít need to worry about that.

When developing the DLL, I suggest that you keep it as a standard EXE project and debug it like that. Then, when youíre ready to test it with ASP, compile it as an ActiveX DLL. This way you can cut out a lot of restarting IIS.

However bad Visual Interdevís debugging features may be for components, make sure that you use whatís available. Turn debugging on for your web site by loading Internet Service Manager, right clicking on your web site and selecting properties. Choose the Home Directory tab and select Configuration (under the Application Settings frame). Now select the App Debugging tab and make sure that Enable Server Side ASP Script Debugging and Enable Client Side ASP Script Debugging are checked. This will allow you to use Visual Interdev to hook onto the IIS process.

OK Ė so you've built your nifty DLL and ASP script, but how do you know how well it will perform? Lets find out...

Testing Your Component
You could ask Microsoft to put your page live on their site for testing, but I donít think they would be too pleased to do that. So, do you invite all your friends around to continually refresh your ASP page as you watch the server crash? No! You go and download the free Microsoft Web-Application Stress Tool of course.

Right, I best be off Ė some more ASP components to write! In the meantime, have fun writing components for ASP (youíll know what I mean when youíve finished doing it, not during!) If you come across any more tips please let me know and I'll post them to this page. If youíve got anything to say about this article or want to ask questions, please use the Post Feedback Now link at the bottom of this page. If you would like to send me cheques, gifts or other forms of thanks, use my email address: sam@devarticles.com.
DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

blog comments powered by Disqus

- Central Scoreboard with Flash and ASP
- Calorie Counter Using WAP and ASP
- Creating PGP-Encrypted E-Mails Using ASP
- Be My Guest in ASP
- Session Replacement in ASP
- Securing ASP Data Access Credentials Using t...
- The Not So Ordinary Address Book
- Adding and Displaying Data Easily via ASP an...
- Sending Email From a Form in ASP
- Adding Member Services in ASP
- Removing Unconfirmed Members
- Trapping HTTP 500.100 - Internal Server Error
- So Many Rows, So Little Time! - Case Study
- XDO: An XML Engine Class for Classic ASP
- Credit Card Fraud Prevention Using ASP and C...

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials