Setting Global Variable in Web.Config is indeed very good practise. Alternativly, you can even Set up Session variables at different stage.
You can set Session["Name"] variable inside your application anywhere. & they will be available to your application from anywhere. If you want something to initialize at StartUp then you can write your code in Global.asax file.
Another good thing about Session variable is they are objects. So, you can store anything inside Session variable.. starting from string, integer, Array to even DataSet or DataView.
ex.
Session["Name"] = "Tushar";
string strName = Session["Name"].ToString()
-tushar
Main Topics
Browse All Topics





by: servicegroupPosted on 2004-10-18 at 06:51:12ID: 12338295
You can use the web.config file to store "global variables"
ettings["a dminEmail" ]; //after this, the variable admin will have the value "admin@admin.com"
First insert the data in web.config
After the "</system.web>" line, insert these values:
<appSettings>
<add key="adminEmail" value="admin@admin.com"/>
</appSettings>
Where the variable name is called adminEmail.
In the csharp side
using System.Configuration; //place this line before the namespace declearation
string admin = ConfigurationSettings.AppS
Let me know if that solves your problem
-Jim