Adam Bickels
Adam Bickels

Reputation: 471

Change or add connection string in the App.config programmatically using MVC 3

Is is possible to add or change connection in the connection string in the App.config, programmatically? I've tried something with

    var A = ConfigurationManager.ConnectionStrings;
    A.Add(new ConnectionStringSettings());

but i got a message that it's read only.

Please help

Upvotes: 1

Views: 571

Answers (1)

Levi Botelho
Levi Botelho

Reputation: 25234

Any modification to the configuration file of a web application requires IIS to restart. As such, you cannot make a runtime modification to the file from your code because it would require restarting the entire application.

Upvotes: 1

Related Questions