ASP - Share application variables

          Sample for Multi.Dictionary.Connect 

Examples
      ScriptUtilities MultiDictionary lets you share variables (text, numbers, objects) in one process. This is idea sample to share ASP (ASPNet) Application objects between two or more IIS applications. You can share any type of variables - strings, numeric, arrays, objects with a top performance.
      You can also use Access ASP Application object from a remote script article (without external components). This article lets you share strings/numeric variables over internet (other ASP apps on the same or remote machine, VBS scripts).
ASP - Share application variables 
'Global.asa of application1:
<Object RunAt=Server ID=AppShare ProgID=Multi.Dictionary Scope=Application></Object>
<SCRIPT LANGUAGE=VBScript RUNAT=Server>

Sub Application_OnStart
  AppShare.Connect "Applications"
  AppShare.Remove "A1"
  Set AppShare("A1") = Application
  Application("Key1") = "Some value"
End Sub

Sub Application_OnEnd
  AppShare.Remove "A1"
End Sub

</SCRIPT>


'Global.asa of application2:
<Object RunAt=Server ID=AppShare ProgID=Multi.Dictionary Scope=Application></Object>
<SCRIPT LANGUAGE=VBScript RUNAT=Server>

Sub Application_OnStart
  AppShare.Connect "Applications"
  AppShare.Remove "A2"

  Set AppShare("A2") = Application
  Application("Key1") = "Some other value"
End Sub

Sub Application_OnEnd
  AppShare.Remove "A2"
End Sub
</SCRIPT>

'Some ASP file in application1 can access both Application objects from App1 and App2:
<%
Response.Write "<br>Key1 from this application : " _
  & Application("Key1")
Response.Write "<br>Have we connect to other app? : " _
  & IsObject(AppShare("A2"))
If IsObject(AppShare("A2")) Then
  Response.Write "<br>Key1 from other application : " _
  & AppShare("A2")("Key1")
End If
%>

Script output:
Key1 from this Application : Some value
Have we connect To other app? : True
Key1 from other Application : Some other value
  Other links for ASP - Share application variables
Free threaded dictionary object. Lets you work with unique/non-unique keys, any VARIANT values and connect to other dictionary in the same process.
     Dictionary is a COM class specially designed as a free-threaded dictionary in Application scope of ASP/ASP.Net pages. It also works with script other engines in VB Script and JScript (ASP,ASP.Net, WSH, CHM, HTA), VB Net, Visual basic (VBA - VB 5, VB 6, Word, Excel, Access, …), C#, J#, C++, ASP, ASP.Net, Delphi and with T-SQL OLE functions - see Use ByteArray object article. You can also use the object in other programming environments with COM support, such is PowerBuilder.
     Source code for Dictionary is available within distribution license, please see License page for Multi Dictionary or License page for ScriptUtilities and Huge ASP file upload.
Multithreaded dictionary object. Lets you work with unique/non-unique keys in VBA/VBS/ASP/WHS envinronment (share application/session variables in ASP)

© 1996 – 2005 Motobit Software, help{at}pstruh.cz, help v. 2.16.14