简体   繁体   中英

Application wide Constant on Application Load in ASP.NET C#

I wish to read a yaml file, deserialize it and store it as a constant till tne next time the website is rebuilt again in ASP.NET C#.

What would be the way to do it in ASP.NET C#?

Application start in Global.asax.

Read in the file and store as a static variable. Use a lock to avoid multithreading issues when modifying that variable (ie the initial load).

http://msdn.microsoft.com/en-us/library/ms178473%28v=vs.100%29

You could read in the file in and generate code for a class to hold data as a constant. Write a script to compile the class to a dll. Then you need a reference and using statement in whatever program is using this configuration. You would need to run the scripts each time the site was built.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM