How to create website specific configuration files while running multiple ASP.NET websites on a single code base?
I want to create 2 websites on a single code base in asp.net. lets for say :
www.domain1.com
www.domain2.com
I need to keep all the appsetting key name sames but with different values for each of the websites.So i need to maintain two web.config files in my code base.
After exploring on internet , i found to keep both of the web.config files in different folders in the code base.
Bow the problem is, how can i link each of the different web.config file with its corrosponding Virtual directory for each the website because both of the Virtual directories wil开发者_如何转开发l target the same folder of code base.
I really neede it as i have to finish this work within this week.
Thanks
If you really want to serve both site from one application/virtual directory, the only solution I can come up with is as follows:
<appSettings>
<add key="setting[www.domain1.com]" value="foo" />
<add key="setting[www.domain2.com]" value="bar" />
...
And then access these accordingly:
var setting = ConfigurationManager.AppSettings["setting[" + request.Domain + "]"];
精彩评论