You can expose your class via COM for use in ASP:
On your class declare a System.Runtime.InteropServices.GuidAttribute("[guid goes here]"). You can obtain a Guid in the appropriate
format by using VS.NET. Go to Tools --> Create GUID. This assigns your soon-to-be COM object that can be used in ASP a unique GUID
that will be registered with Windows.
Your class will be registered with an automattically generated ProgID made up of the Namespace and Class name and with the GUID you
have assigned using the GuidAttribute. Use the ProgIdAttribute if you wish to hard-code a programmatic identifier for your class.
It is recommended that you hard-code the GUID since VS.NET will generate one for you otherwise and it will change upon successive
builds. If neither a ProgID or Guid is specified for your class, it will not be registered for COM Interop unless you specify the
ComVisible attribute as System.Runtime.InteropServices.ComVisible(true).
Again, I recommend just using the GuidAttribute stand-alone.
In the Project settings dialog of the project that contains your class, select the "Configuration Properites" node, then "Build"
node and set "Register for COM Interop" = "true".
When you build your application, VS.NET will register your assembly for COM interop by checking for classes with the attributes I've
mentioned above and if appropriate, registering them with Windows.
This is the command-line utility that you can use to do this manually:
%windir%\Microsoft.NET\Framework\v1.1.4322\RegAsm.exe
In ASP create an instance of the object as you would using a ProgID, for example, with an ADODB.Connection. Here is how you would
access your object via scripting if your class was in the namespace, "MyNamespace" and was named, "MyClass":
VBScript:
Dim conn: Set conn = CreateObject("MyNamespace.MyClass");
JScript:
var conn = new ActiveXObject("MyNamespace.MyClass");
Note that for production servers your going to have to register the assembly manually since it's not a good idea to install VS.NET
and build on live servers. Check out the RegAsm.exe utility that I've mentioned above. It's a command-line utility only.
I suggest creating a Setup and Deployment project for your web site if you are going to be using a live server, and automate the
registration using the installer.