ASP.NET config data
I'm working with ASP.NET and c#. I don't know where to store the configuration setting for my web app.
Every time a page loads the app reads the master page. On the master page, everytime I need to get the following data:
Meta Tags for the site The users have to be able to change this data in their CMS, so I think the best for this is to store in the database. So every time a user request a page the web app is going to query the database.
Some configuration like the master page we are using (we use several for several templates), and some other config. We think we can store this in the web.config since users can't modify these values.
In the past we used an xml file to read the Meta Tags, but we ythink is better开发者_如何学运维 to use the database.
Also, does it cost a lot for the web app to access the web.config in every page? I mean, to do "ConfigurationManager.AppSettings["variable"];"
Thanks a lot !!!
ConfigurationManager.AppSettings["variable"]
value is remained and picked from cache, until web.config changes.
you can also store application setting in xml file in App_Data
folder, and mentioned in web.config like:
<appSettings configSource="App_Data\Config\siteConfig.xml" />
For Metatags a database storage will be better. You could use the ASP.NET cache object to improve performance so you don't have to get the info from DB on every request. You could use a time based expiration for the data or even sql based expiration trigger.
The web.config file is not accessed every time an item is read. It's stored on memory so there is no performance hit on using it.
Web.Config Ok, but if web.config is stored in memory and the site has tons of visits, is this good for performance?
Meta Tags can you give me an example on how to use ASP.NET cache object to store META-TAGS? In this case with a lot of visits is also better to use cache instead of access to database on every request? The cache object is for every user/session on all the users share that object? It'd be better that all the users use the same cache object. This way the firsat one access to the database and the rest get the cache object. Is possible to do this way?
Thanks a lot for you answers
精彩评论