Depending on your database connection system, you could supply it with a connectionstring based on a usersetting rather than based on the web.config? There has to be some way of deciding which database a user wants to use, this could be something as simple as buttons or dropdown list for selecting, or keep the system with two folders but use an URL route to make them both point to the same files. Then when you instantiate your database connection you can supply the correct connectionstring and you're set.
Edit: After chat the solution has been to put two connectionstrings in web.config
, one for the Test database and one for Production. Then add routing to pretend the two folders are still there, with the following basic idea:
routes.Add(new Route("{folder}/{page}", new PageRouteHandler("~/{page}")));
Lastly a function to decide which connectionstring to use based on the folder
value in the routing values: Request.RequestContext.RouteData.Values["folder"]
, and a global refactor to use this dynamic connectionstring rather than a hardcoded one.
For having "multiple" web.configs, you can make a config section specific to a file path, see http://msdn.microsoft.com/en-us/library/b6x6shw7%28v=vs.71%29.aspx However I am not sure wheter this works for connectionstrings.
Example:
<configuration>
<location path="Logon.aspx">
<system.web>
<authorization>
<allow users="?"/>
</authorization>
</system.web>
</location>
</configuration>