1

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 will target the same folder of code base.

I really neede it as i have to finish this work within this week.

Thanks

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
Rupendra
  • 608
  • 2
  • 11
  • 42

1 Answers1

1

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 + "]"];
Anthony Pegram
  • 123,721
  • 27
  • 225
  • 246
Anton Gogolev
  • 113,561
  • 39
  • 200
  • 288
  • It's like adding up two keys for same work. Is not it? I dont want to maitain two keys for a work as it will impose a big code change on my team in the current code base. Rather i want to keep same key for a work for both of the websites to avoid major code changes. If it would be so simple, then i wouldn't ask such a question. Is not it Mr Anton ? – Rupendra Sep 30 '11 at 07:23
  • Not sure I understand you. Having twice as many keys in a single `web.config` is IMO better than having two separate `web.config`s with all the heavy duplication. – Anton Gogolev Sep 30 '11 at 07:26