Modifying in-memory connection string
Hello,
I need to deploy data driven web sites for dozens of clients. Each client will have their own URL and their own SQL Server database, but the actual code (.aspx files, .aspx.cs files, .gif files, etc.) of each site is exactly the same. Obviously, I don't want to duplicate the code for each site.
I'm thinking of using this solution:
* Have just one directory with all the files, including the web.config, and point all URLs to that one directory.
* Have a separate database for each site, with the same name as its URL - so the site "bigclient.com" would have database "bigclient.com", etc.
* Do something clever in the Global.asax, so when a site starts up it changes its cached connection string - to make it use the database matching the url of the site.
I know how to change the connection string in the web.config file. However, because there would be only one web.config, if one site updated the web.config file with its connection string, this would affect all other sites. So I want to update the in-memory connection string only, not the actual web.config file.
I could change the code so all sites use the one database, and add a "url" field to all tables. However, this would be a lot of work. I'd much prefer to have each site change its own in-memory connection string on startup if possible.
How do I do this?
Is there a better way of solving the "1 set of source files, multiple databases" problem?
Thanks in advance for your help,
Matt Perdeck
|