Reputation: 35
I am starting Asp Net MVC4 project and since I am comming from php development I am curious about what would it be the best way to set-up a configuration file to store parameters like system name, version and others that I might need.
Is there any guideline to do that for instance using a config file or a database query..?
Upvotes: 3
Views: 2975
Reputation: 6607
I use web.config extensively for this type of thing.
Example
<appSettings>
....
<add key="SearchUserResultMaxCount" value="100" />
</appSettings>
Code
public static class SearchHelper
{
/// <summary>
/// Gets the max records for resultset from db, configurable in web.config
/// </summary>
/// <returns></returns>
public static int SearchEntityResultMaxCount()
{
int count;
Int32.TryParse(ConfigurationManager.AppSettings["SearchEntityResultMaxCount"], out count);
return count;
}
}
Upvotes: 5