Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Major mixup in two ASP.NET transactions
Message
 
To
03/09/2006 11:16:35
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
VB 8.0
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01150471
Message ID:
01150645
Views:
36
You can - you need to use static properties.

I have a static App object in my application for example. It has static properties for things like my Configuration manager, my localization manager and a handful of constants that are used through out the application.

There's a static constructor on that object that sets up these properties. The static constructor is guaranteed to fire only once per application.

For example:
public class App
{
    public static wwAppConfiguration Configuration;
    public static wwLocalizationManager Localization;
  
    public static string WWSTORE_APPNAME = "West Wind Web Store";

    public static App()
    {
          Configuration = new wwAppConfiguration();
          Configuration.EncryptFields("MailserverPassword,MerchantPassword");
          Localization = new wwLocalizationManager();
          Localization.ConnectionString = Configuration.ConnectionString;
    }
}
Now from anywhere in the application you can reference:
busCustomer Customer = new busCustomer();
Customer.ConnectionString = App.Configuration.ConnectionString;

string LocalizedString = App.Localization.Localize("ThisWord");

Response.Write(App.WWSTORE_APPNAME);
You can also attach these static properties to your _global object, but I would not recommend it. Using a separate object like the above the object isn't tied to your front ASP.NET layer and instead can live in your business layer and be reused. So for example, in my Web Store application I use the same App object in the Web app and the Windows Forms offline app for it.


I would highly recommend you do a little reading on VB.NET or C# and a learning about how the CLR works. For the kind of stuff you are doing this is important. I recommend Jeffrey Richter's book on the CLR which is a great introduction to the .NET framework architecture.

+++ Rick ---

>Correct, but I need to have the Initialize() method of the framework to be executed only once. This takes some time and all the core framework initialization is in there. I cannot afford to redo all that for every hit. When I was using WWWC framework, I implemented a way to have everything loaded in memory for the first hit of every WWWC instance I had in memory. Then, on the next hits, everything was extremely fast. I cannot think I wouldn't be able to achieve that in .NET. I cannot think everyone is building application that are initializing everything on every hit.
+++ Rick ---

West Wind Technologies
Maui, Hawaii

west-wind.com/
West Wind Message Board
Rick's Web Log
Markdown Monster
---
Making waves on the Web

Where do you want to surf today?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform