Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / April 2008

Tip: Looking for answers? Try searching our database.

Multiple config files

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Fresno Bob - 20 Apr 2008 06:29 GMT
I quite like to store variables in the web.config file. However it can make
the web.config messy and make deployment fiddly. Is there any way of have
multiple web.config files - one with the major stuff and one with minor
stuff such as my variables which can differ from development to production.
Or alternatively is there some kind of tool to make the deployment smoother?
Regards, Chris.
Robert Cramer - 20 Apr 2008 09:20 GMT
Option 1: Create your own XML files. Name them whatever you like - even with
a .config extension (as long as the rest of the name doesn't conflict with
the convention expected by .NET, which is ApplicationName.config - the name
that Web.config takes after compilation). Then read your XML files as plain
ole' XML documents, parsing out your configuration values however you like.

Option 2: Store your config values in a database and retrieve them as
necessary and/or during Application_Start.

Option 3: Have multiple Web.config files. In order to do this, the files
must exist at different levels in, or relative to, the application. Config
files can or do exist at the server level, the site level (in the site
root), or in sub folders. If in sub folders, then the settings apply to only
the pages etc within the respective sub folders. But as far as having
multiple config files at the same "level" (e.g., in the site root), I
believe this is not possible, unless you go witth reading them as plain ole'
XML documents and not reading them via the .NET configuration system.

-HTH

>I quite like to store variables in the web.config file. However it can make
>the web.config messy and make deployment fiddly. Is there any way of have
>multiple web.config files - one with the major stuff and one with minor
>stuff such as my variables which can differ from development to production.
>Or alternatively is there some kind of tool to make the deployment
>smoother? Regards, Chris.
Patrice - 20 Apr 2008 10:32 GMT
Plus :

- I remember to ahve seen that you can reference include files from your
web.config file (made a qucik search and it looks like this is done using
the configSource attribute)

- you can put all settings in a single web.config file and retrieve the
appropriate section/entry based on the current host name

--
Patrice

> Option 1: Create your own XML files. Name them whatever you like - even
> with a .config extension (as long as the rest of the name doesn't conflict
[quoted text clipped - 23 lines]
>>production. Or alternatively is there some kind of tool to make the
>>deployment smoother? Regards, Chris.
Marc Scheuner - 20 Apr 2008 12:07 GMT
>I quite like to store variables in the web.config file. However it can make
>the web.config messy and make deployment fiddly. Is there any way of have
>multiple web.config files - one with the major stuff and one with minor
>stuff such as my variables which can differ from development to production.
>Or alternatively is there some kind of tool to make the deployment smoother?

You can define a "configSource=........" attribute for just about
every section in your web.config, to "externalize" your config
settings to separate files:

<?xml version="1.0"?>
<configuration>
  <system.web>
    <pages>
    ...
    </pages>
  </system.web>
  <system.serviceModel>
      <bindings configSource="serviceModel_bindings.config"/>
      <client configSource="serviceModel_client.config"/>
     .......
   </system.serviceModel>
   <connectionStrings configSource="connectionStrings.config" />
.......
</configuration>

Those external config files now simply contain the section that you
would normally have directly in your web.config, e.g.

connectionStrings.config:

<?xml version="1.0" encoding="utf-8" ?>
<connectionStrings>
  <add name="default" connectionString="........"/>
</connectionStrings>   

That alone can make your web.config a lot more readable right there -
and it's totally built in, no extra custom code needed - nada.

Hope this helps.
Marc
Fresno Bob - 22 Apr 2008 08:33 GMT
I'll have a look at that. It looks like exactly what I'm looking for.
Cheers.

> >I quite like to store variables in the web.config file. However it can
> >make
[quoted text clipped - 40 lines]
> Hope this helps.
> Marc

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.