Reputation: 2385
I have an ASP.NET MVC application that I distribute as a zip file to customers. They then extract it on their servers. Everything is stored in a SQL database, but I need to save the connection string and that will get overwritten if it's stored in the web.config and they just copy over all the files. The current implementation creates a simple file in the site directory with the connection string, but in some cases the app pool identity doesn't have permission to write to the filesystem.
My first thought was the registry, but it sounds like I'll run into similar permission issues. Is there a directory that I'm guaranteed to have access to? Another option would be to have an installer perform this action, but I'd prefer not to have to write an installer.
Anything I'm overlooking?
Upvotes: 1
Views: 160
Reputation: 888223
You can use configSource
to load it from a different config file, which you would never overwrite when deploying updates.
This works if you expect customers to manually write that file on initial setup.
If you want them to enter the connection string into a UI, the registry (in HKCU only) should be fine; you should (almost) always have permission to write to the user registry, regardless of filesystem permissions.
Upvotes: 2