Register
|
Articles
|
Questions
|
Projects
|
Asp.Net Tips
|
Free Magazines
|
Tutorials
|
Search
|
Write to us
|
Login
Search
Articles
Asp.Net 2.0
AJAX
ADO.Net
C#
Javascript
Books
Asp.Net 2.0
AJAX
ADO.NET
C#
JavaScript
MS SQL Server
SilverLight
VB.NET
XML
Web Service
Resources
Asp.Net News
Downloads
Free Tech Magazines
Asp.Net Web Hosting
Archives
Softwares
Newsletter
Suggest Us
Link to Us
Feeds Subscription
Articles
Questions & Answers
Tips & Tricks
How To use two Web.Config Files in Asp.Net Application?
Posted by
Moderator1
on
3/27/2010 10:54:00 PM
2124
Views
This tip’s will help you to maintain two web.config files in an Asp.Net web application. The known factor is, by default, every web application will have single config file named as “Web.Config”. You can add keys and values under the <appSettings/> tag and retrieve it from the web application code-behind. For some additional purpose, the application can have more than one config file. But the application can recognize the file named as “Web.Config” or the only config file available in the application. So let us examine how we can make the application to retrieve the values from the second config file.
Step 1: In the Asp.Net web application, add the second web.config file named as “Web2.config”
Step 2: Remove all the default tags in Web2.Config file and add only <appSettings/> tag and its key-value as follows.
<appSettings>
<add key="TestKey" value="Test Value From Web2.Config"/>
</appSettings>
Step 3: In the default Web.Config file, at the <appSettings> tag, add an attribute as ‘file="Web2.config"’ as follows.
<appSettings file="Web2.config">
</appSettings>
Step 4: Now access the value from the second config file as usual.
Response.Write(ConfigurationManager.AppSettings.Get("TestKey"));
Post New Tips/Tricks
View all Tips/Tricks
Featured Resources:
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time.
Building a Web Application Security Program
Learn how to build a pragmatic web application security program that constrains costs while still providing effective security.
100% Free Subscription until Stock lost.
View complete list.
Sponsored by
Home
About us
Contact Us
Links
Advertise
Privacy Policy
Copyright ©
2012
. www.AspdotnetCodes.com. All rights reserved.