Gui*_*.I. 3 asp.net-mvc configuration-files asp.net-mvc-4
我正在启动Asp Net MVC4项目,因为我是从php开发中来的,我很好奇它是设置配置文件以存储我可能需要的系统名称,版本和其他参数的最佳方法.
是否有任何指导方法可以做到这一点,例如使用配置文件或数据库查询..?
我广泛使用web.config来处理这类事情.
例
<appSettings>
....
<add key="SearchUserResultMaxCount" value="100" />
</appSettings>
Run Code Online (Sandbox Code Playgroud)
码
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;
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2919 次 |
| 最近记录: |