[RESOLVED]Change path to web.config at runtime

Is there any I could change the path to web.config at runtime?

By default, it’s ~/web.config.

I want to change it to ~/test/web.config.

And upon doing so will the Application restart?

tried this, won’t work

 var basePath = Server.MapPath("~/");
  AppDomain.CurrentDomain.SetupInformation.ConfigurationFile = Path.Combine(basePath, "webtest.config");

Hi,

You would likely need to intervene earlier at AppDomain creation. Maybe

http://blogs.msdn.com/b/suzcook/archive/2003/06/02/57160.aspx

Also the location does matter (having web.config files in subfolders is allowed so it would likely conflict with this usage) so for now it seems quite a complex choice.

Is this just to select a test or a prod config depending on which location you are deploying to?

Leave a Reply