Tuesday, April 17, 2007

Web.config - Using an External File

You may find it necessary to separately manage a particular section of your web application's configuration.

Say, for instance, you want to manage a single code base (one web.config file) but you want the application to behave differently on different servers (development, QA, production).

ASP.NET 2.0 allows you to modularize a configuration section using the configSource attribute. The following is an illustrative example:

MyApp has a web.config file that specifies an external source for the appSettings section:

You can store the external file, appSettings.config, anywhere within the application, provided the configSource attribute must specifies a virtual path. Sorry, physical paths or paths outside the application are prohibited.

Getting back to the example, appSettings.config contains a well-formed <appSettings> section:

That's all there is to it! To test the retrieval of these settings, here is a simple .aspx form, testconfig.aspx:

Finally, here's what the output looks like when you visit http://localhost/myapp/testconfig.aspx:


Link to Cut-and-paste-friendly code

14 comments:

Anonymous said...

Hi,

When ever I surf on web I never forget to visit this website[url=http://www.weightrapidloss.com/lose-10-pounds-in-2-weeks-quick-weight-loss-tips].[/url]diablopup.blogspot.com is filled with quality info. Do you pay attention towards your health?. In plain english I must warn you that, you are not serious about your health. Recent Research points that closely 90% of all USA grownups are either obese or overweight[url=http://www.weightrapidloss.com/lose-10-pounds-in-2-weeks-quick-weight-loss-tips].[/url] Therefore if you're one of these individuals, you're not alone. Its true that we all can't be like Brad Pitt, Angelina Jolie, Megan Fox, and have sexy and perfect six pack abs. Now next question is how you can achive quick weight loss? [url=http://www.weightrapidloss.com/lose-10-pounds-in-2-weeks-quick-weight-loss-tips]Quick weight loss[/url] is really not as tough as you think. If you improve some of your daily diet habbits then, its like piece of cake to quickly lose weight.

About me: I am author of [url=http://www.weightrapidloss.com/lose-10-pounds-in-2-weeks-quick-weight-loss-tips]Quick weight loss tips[/url]. I am also health trainer who can help you lose weight quickly. If you do not want to go under difficult training program than you may also try [url=http://www.weightrapidloss.com/acai-berry-for-quick-weight-loss]Acai Berry[/url] or [url=http://www.weightrapidloss.com/colon-cleanse-for-weight-loss]Colon Cleansing[/url] for effortless weight loss.

How to lose weight fast? said...

Lots of people have asked us about the fastest and best "easy" way to lose weight... so I'll try to answer that in this post. I'll go over a few simple techniques that are proven to help just about anyone burn fat, lose pounds, and shed weight in a quick and relatively easy way...First off, when people say they want an easy weight loss solution that usually means that they don't want to do any exercise. "No exercise" weight loss plans can work but they usually don't provide the best possible results. Even a small amount of exercise can provide big benefits that diet-only weight loss plans simply can't match. Plus, with just a small amount of efficient exercise, the pounds will actually come of more easily in the end!The key to dropping weight quickly and in the easiest possible fashion is to eat only good foods, avoid all bad foods, do a small amount of exercise regularly, and take a few cheap supplements that help to optimize your metabolism in a way that speeds up fat loss. Follow the tips below and you should have no problem losing 10-20 pounds within the next month...

Panky said...

Hi wt if i have multiple Location Tags to be added in a sepearte config file and want my web.config to refer all those location tags from external file?

eco travel agency costa rica said...

Hi buddy, firstly I would like to send greetings to all readers then I think that this information is amazing and very entertainment information, I was looking information about Web.config - Using an External File , and this information is very professional and I would like to have any update about, thanks for sharing!!

Anonymous said...

Restaurants in the United States. Search or browse list of restaurants. http://restaurants-us.com/pa/Erie/Pufferbelly%20Restaurant%20&%20Bar/16507/

Green Parks said...

Hello.. Firstly I would like to send greetings to all readers. After this, I recognize the content so interesting about this article. For me personally I liked all the information. I would like to know of cases like this more often. In my personal experience I might mention a book called Green Parks Costa Rica in this book that I mentioned have very interesting topics, and also you have much to do with the main theme of this article.

Anonymous said...

Like james wrote it is correct

Anonymous said...

Can I just say what a relief to find someone who actually knows what theyre talking about on the internet. You definitely know how to bring an issue to light and make it important. More people need to read this and understand this side of the story. I cant believe youre not more popular because you definitely have the gift. Maria - california auto insurance

muebles en guadalajara said...

I found a lot of helpful info here!

Anonymous said...

It's area of the Eastern Division, AFC within the National football leagueRon Raymond Stanley Cup Picks*Note: You can bet these picks at Bodog That's everything really matters It was set up in 1932 in Boston, earlier called the Boston Brave Team, and at that time the boss of the team was George Preston Marshall I even can't [jet fleet to coach],, this is part of the crazy about it in the store bartering and organization affiliation forecasts
Some of the rules you need to know about the Russian language are: 1 You can also publish their books or videos, if these products are related to your industry or niche and they do not to compete with your? own productit is surprising for his size, but he doesn consistently push and doesn the pile really possess optimal leg drive This game marked a turning point for Rivers, who aided by head coach Marty Schottenheimer's opening of the playbook, led the team in a come-from-behind victory throwing 24-of-37 for 242 yards and two TDs, winning 23 3 He has tied an NFL document with nine touchdown passes above the 1st two weeks of a season It consequently, gets really hard for you to verify the authenticity of a shirtLater, in the dark of night, the flood would reverse, with giddy Bills fans returning home declaring an unlikely victory over Tom Brady and New England Patriots to customs officials
Does the School offer Mortgage education courses that are accessible 24/7 and 100% onlineMake sure your NMLS classes are truly 100% online The explanation of the theorem must be given in the statements section While it's just a start, you're unlikely to find out an enormous begin free internet streaming owing to current contracts which give cable and satellite provider exclusive package offers It is not simple to inform them apart Candiate is not able to ask each and every thing about the thesis from the guide due to the hesitation so a sample thesis can workas a guideShare your answer Wearing for three dunk king, now plays for the Thunder Nate - Robinson is concerned, NFL shut down coming to an end as good as a good news, because recently he said that once the NBA long-term shut down, he would consider his previous profession, joined the NFL to play football

[url=http://www.redskinsnflprostore.com/london-fletcher-jersey-elite-c-6_44.html]london fletcher jersey white[/url]
[url=http://www.nikebroncosjersey.com/nike-peyton-manning-womens-jersey]Peyton Manning Youth Jersey[/url]
[url=http://www.nikebroncosjersey.com/nike-champ-bailey-womens-jersey]Broncos Champ Bailey Jersey[/url]

Anonymous said...


Cialis[url=http://www.cialis.gd]Cialis[/url]http://www.cialis.gd
Viagra[url=http://www.viagra.gd]Viagra[/url]http://www.viagra.gd
Levitra[url=http://www.levitra.gd]Levitra[/url]http://www.levitra.gd

Anonymous said...

Issuereot xaikalitag tastspealkifs [url=http://uillumaror.com]iziananatt[/url] HeariCicnoinc http://gusannghor.com creelaync

Anonymous said...

unique capacity to analyze, compare and cialis price cialis price,cialis online generic cialis, viagra online cialis,viagra online cialis price
http://genericcialispricegnf.com#cialis online http://cialisonlinepillsgkd.com#cialis pills http://genericviagraonlinejvrg.com#viagra http://buyviagraonlinertvr.com#buy viagra

Anonymous said...

physician ignorance, from rogue Internet generic cialis generic cialis,cialis cialis, viagra online cialis,viagra cialis price
http://genericcialispricegnf.com#cialis http://cialisonlinepillsgkd.com#cialis pills http://genericviagraonlinejvrg.com#viagra http://buyviagraonlinertvr.com#buy viagra