Wednesday, March 30, 2022

ASP.NET connection string in web.config in appsetting section Configuration.cs

 The file will be stored in App_Code/Common

web.config file

<appSettings>

    <add key="ConnectionString" value="Server=DESKTOP-EUCFT2Q; Database=Test; UID=sa; PWD=password;Min Pool Size=20; Max Pool Size=200"/>


</appSettings>


------------------------------------------


using System;

using System.Collections.Generic;

using System.Text;


//Add reference to System.Web if not yet referenced

using System.Web;

using System.Web.Configuration;


namespace Luminious.Connection

{

    public abstract class Configuration

    {

        public static String ConnectionString

        {

            get

            {

                return WebConfigurationManager.AppSettings["ConnectionString"];

            }

        }

      

    }

}


No comments:

Post a Comment