ASP.NET/C# Read web.config settings method

internal static string GetSetting(string key, string defaultValue){    try    {        object setting = ConfigurationManager.AppSettings[key];        if (setting != null && setting.ToString().Length == 0)        {            setting = null;        }        return (setting == null) ? defaultValue : (string)setting;    }    catch    {        return defaultValue;    }}

Leave a Reply

Your email address will not be published. Required fields are marked *