29 May 2012

Use Application Wrapper Class To Access Web.Config Values


Use Application Wrapper Class To Access Web.Config Values

Make sure you have a Reference to the System.Configuration.DLL

using System;using System.Collections.Generic;using System.Configuration;using System.Web;

public static class ApplicationWrapper{    #region public members
    
public static string DBConnection
    {
        
get { return ConfigurationManager.ConnectionStrings["DBConnection"].ConnectionString; }
    }
    
public static int MaxLoginAttempts
    {
        
get { return int.Parse(ConfigurationManager.AppSettings["MaxLoginAttempts"]); }
    }
    
public static string Company
    {
        
get { return ConfigurationManager.AppSettings["Company"]; }
    }
    #endregion}



No comments:

Post a Comment

Comments Welcome