I am trying to refactor a classic asp code base. For the most part it is going well. It had lots of code duplication for different language versions of the site, so for 6 languages the site was replicated 5 times.
I have used json language files and have managed to make it all far more dynamic and it works lovely.
What I am trying to do now is make the Language class a global object throughout the application for ease of use.
I have used global.asa but the instructions and tutorials I find are very minimal and don't really carry anything I am understanding properly.
I have 2 files:
global.asa
<!--#include virtual="/Five/Classes/Language.asp"-->
<object runat="server" scope="session" id="Lang" progid="Language">
Lang = New Language
</object>
and test.asp
<%
Lang.LoadLanguageFile("reportAbuse")
%>
<%= Lang.iString("strTitle") %>
what happens though is I receive
Microsoft VBScript runtime error '800a01a8'
Object required: 'Lang'
/Five/0/test.asp, line 2
I cannot, having looked all around here and the web find anything more than:
GLOBAL.ASA:
<object runat="server" scope="session" id="MyAd" progid="MSWC.AdRotator">
</object>
You could reference the object "MyAd" from any page in the ASP application:
SOME .ASP FILE:
<%=MyAd.GetAdvertisement("/banners/adrot.txt")%>
You cannot use VBScript classes as persisted objects in Classic ASP. The example you give is a COM object scoped to the session which is different from using a POCO class in VBScript.
If you want to implement a scoped COM object you would need to build a DLL and implement your class there then expose it to COM registering it where it can then be accessed via Classic ASP. However, you will probably have issues with the data being persisted (see link).
There may be some special-ist requirements for a COM library scoped to a session but I'm not aware of any.