Skip to content

When I browse from IIs not add connection string to webconfig file

Sumi D

Asked Nov 25, 2011, 9:06 PM EST2 answers
Share
LinkedInX
System.Configuration.ConnectionStringSettings connection = new

System.Configuration.ConnectionStringSettings("helloConnectionstring5", constr, "System.Data.SqlClient");
var settings = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(@"/");
settings.ConnectionStrings.ConnectionStrings.Add(connection);
settings.Save();
Global.StartupType = Global.STARTUP_TYPE.NORMAL;
lblstatus.Text = "Connection success and connectionstring updated in webconfig";


this is my code for adding connectionstring in webconfig file.
But this working in my local system.
after configuring IIS.when I browse from there it wont add connection string to webconfig file.

2 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • Suthish Nair
    0
    Hi Welcome to C# Corner..

    when I browse from IIs?


    Can you explain this line...

    Refer

     Link1 Link2
    0
  • 0
    hi

    when I browse from there it wont add connection string to webconfig file. it means,

    after the configuration from IIS ,when I browse the  addconnectionstring page from IIS,and giving the values from there the conncetionstring is adding somewhere but it  wont add connectionstring string in webconfig file for that application

    can you plz help me.? this is the code.

            System.Configuration.ConnectionStringSettings connection = new         System.Configuration.ConnectionStringSettings("helloConnectionstring5", constr, "System.Data.SqlClient");
                var settings = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(@"/");
                settings.ConnectionStrings.ConnectionStrings.Add(connection);
                settings.Save();
                Global.StartupType = Global.STARTUP_TYPE.NORMAL;
                lblstatus.Text = "Connection success and connectionstring updated in webconfig";


    Please help me.
    0