Search code examples
iisiis-10

Why doesn't IIS allow me to change the connection string name?


In IIS, I can configure any number of DB connection strings on a given node:

IIS connection strings list

When creating a new connection string, I can enter any name I like into the Name text box:

Add connection string dialog box

However, when editing the connection string, the Name text box is read-only:

Edit connection string dialog box

Why is it read-only? Am I not supposed to change a connection string's name?

Note that I can still change the name, of course, by editing the underlying Web.config file manually. And that is indeed what I've been doing several times now, but the fact that the UI won't let me change the connection string name after it has been created makes me wonder whether there are any problematic side-effects that I'm not aware of.

Background: The framework of the project I'm working on uses a fixed connection string name, "Default", to load the connection string in plenty of places. This way, quickly switching to another DB can only be done by renaming the connection string in IIS to Default, rather than changing some application setting to temporarily use a differently named connection string.


Solution

  • You can change the IIS site connection string name if its entry type is local. just click on the connection string in which you want to change the name and click on the rename from the action pane.

    enter image description here

    another way is to use iis configuration editor.

    1)open IIS manager, select your site/virtual directory or application.

    2)click on the configuration editor feature from the middle pane.

    enter image description here

    3)in configuration editor windows select the connection string from section drop-down:

    enter image description here

    4)click on the three-dot from the collection, select your connection string, and change the name and close the window and apply the changes.

    enter image description here