Comments/Troubleshooting

The MyInfo component is useful for storing and maintaining the many administrative values that correspond to properties of your web site in general. You may use items like the name of the webmaster, her phone number, and her email address in your applications repeatedly. You could simply declare them all as application-level variables, but this is problematic, since you must save these values through code if you want them maintained through the course of a restart on your web server, for example.

There are two points to remember when using the MyInfo component:

  • Once a property has been created, it is in the MyInfo.XML file forever. You must edit this file by hand to remove it. As this is a small text file, this isn't a huge problem, but it's worth mentioning.

  • You should have only one MyInfo object per site (i.e., you should instantiate just one object per application) because there is only one MyInfo.XML file. This file could conceivably be in flux due to the actions of one MyInfo object while you are attempting to read or change a value from a second object. Contrary to the Microsoft documentation, your MyInfo object should have application-level, not session-level scope.

You can use either of the following two pieces of code to instantiate a MyInfo object. The first uses Global.asa to call the Server.CreateObject method:

[FROM GLOBAL.ASA] <% ' Declare local variables. Dim appMyInfo ' Instantiate a MyInfo object with Application level scope Set Application("appMyInfo") ...

Get ASP in a Nutshell, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.