I wanted to define a global variable in ASP.NET MVC project which will have static configurations details. Like context name, project name etc. Actually I am working on developing reusable component for which you can set all these variables and include them in the project such that they work.
Just to give an example
using PROJECT_NAME.Models;
using PROJECT_NAME.BizLogic;
PROJECT_CONTEXT db= new PROJECT_CONTEXT;
and rest of the code follows
This way if I code the components, I think I can use them in any project and all I need to do is set these global variables (or rather reference).
Please help me with the following question
1. How can we set such global variable
2. Is there a better way of doing this.
Thanks in advance for your help 🙂
One answer is here:
https://stackoverflow.com/a/5119154/538387
but the best and most professional way to do it, is to implement a thread-safe singletone pattern:
http://csharpindepth.com/Articles/General/Singleton.aspx