Click here to Skip to main content
15,896,557 members

Access to the path '\web.config' is denied.

Revision 3
Hi all,
when adding a new connection string to the web.config file from code file. the following error is occurred. how to rectify this problem.Code is as follows.
C#
System.Configuration.Configuration configuration = WebConfigurationManager.OpenWebConfiguration("~");
        //        AppSettingsSection appSettingsSection = (AppSettingsSection)configuration.GetSection("connectionStrings");
        //        if (appSettingsSection != null)
        //        {
        //            appSettingsSection.ConnectionStrings[key].ConnectionString = value; = "Data Source=" + DbServerName+ ";Initial Catalog=" + DbName+ ";User ID=" + DbUserName + ";Pwd=" +DbUserPass+ "";
        //            configuration.Save();
Posted 14-Nov-12 23:43pm by Narra sreenu.
Tags: ,