<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://forums.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Tips &amp; Tricks</title><link>http://forums.asp.net/53.aspx</link><description>Cool code and exciting examples, provided by our members.</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Re: Configuration Files FAQs (web.config, machine.config...)</title><link>http://forums.asp.net/thread/3157601.aspx</link><pubDate>Tue, 12 May 2009 13:02:05 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3157601</guid><dc:creator>talktoarvind</dc:creator><author>talktoarvind</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3157601.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=53&amp;PostID=3157601</wfw:commentRss><description>web.config file FAQs And other asp.net FAQs

&lt;a href="http://www.faqpanel.com/DotNet.aspx?level=B&amp;amp;slideno=3"&gt; http://www.faqpanel.com/DotNet.aspx?level=B&amp;amp;slideno=3 &lt;/a?</description></item><item><title>Re: Configuration Files FAQs (web.config, machine.config...)</title><link>http://forums.asp.net/thread/2356566.aspx</link><pubDate>Wed, 14 May 2008 08:44:33 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2356566</guid><dc:creator>tvijaybhanu@gmail.com</dc:creator><author>tvijaybhanu@gmail.com</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2356566.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=53&amp;PostID=2356566</wfw:commentRss><description>&lt;p&gt;&lt;img src="http://forums.asp.net/emoticons/emotion-2.gif" alt="Big Smile" /&gt;Web config is an xml file . By using this file we can set application level settings&amp;nbsp; where as Machine config file is also an xml file where we can do machine level settings.&amp;nbsp; so , by using web config file we can do settings which is limited to particular application and if u do settings using machine config file it is applied to all applications.&lt;/p&gt;</description></item><item><title>Configuration Files FAQs (web.config, machine.config...)</title><link>http://forums.asp.net/thread/1736929.aspx</link><pubDate>Sun, 03 Jun 2007 11:35:16 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1736929</guid><dc:creator>dotnetguts</dc:creator><author>dotnetguts</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1736929.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=53&amp;PostID=1736929</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;b&gt;What is Web.Config File?&lt;/b&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;It is an optional XML File which stores configuration
details for a specific asp.net web application.&lt;span&gt;&amp;nbsp;
&lt;/span&gt;&lt;u&gt;&lt;/u&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;u&gt;Note:&lt;/u&gt;&lt;span&gt;&amp;nbsp; &lt;/span&gt;When you
modify the settings in the &lt;span style="font-size:10pt;"&gt;Web.Config&lt;/span&gt;
file, you do not need to restart the Web service for the modifications to take
effect..&lt;span&gt;&amp;nbsp; &lt;/span&gt;By default, the &lt;span style="font-size:10pt;"&gt;Web.Config&lt;/span&gt; file applies to all the pages
in the current directory and its subdirectories.&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;u&gt;&lt;span style="text-decoration:none;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/u&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;u&gt;Extra: &lt;/u&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;You can
use the &lt;span style="font-size:10pt;"&gt;&amp;lt;location&amp;gt;&lt;/span&gt; tag to
lock configuration settings in the &lt;span style="font-size:10pt;"&gt;Web.Config&lt;/span&gt;
file so that they cannot be overridden by a &lt;span style="font-size:10pt;"&gt;Web.Config&lt;/span&gt;
file located below it. You can use the &lt;span style="font-size:10pt;"&gt;allowOverride&lt;/span&gt;
attribute to lock configuration settings. This attribute is especially valuable
if you are hosting untrusted applications on your server.&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;a href="http://dng-config.blogspot.com/" title="Huge Collection of .Net FAQs"&gt;FAQ collected from http://dng-config.blogspot.com/&lt;/a&gt;&lt;/b&gt;&lt;br /&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;b&gt; &lt;br /&gt;&lt;/b&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;b&gt;What is Machine.config File?&lt;/b&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;The Machine.Config file, which specifies the settings that
are global to a particular machine. This file is located at the following path:&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;\WINNT\Microsoft.NET\Framework\[Framework
Version]\CONFIG\machine.config&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&amp;nbsp;&amp;nbsp; As web.config file is used to configure one asp
.net web application, same way Machine.config file is used to configure the
application according to a particular machine. That is, configuration done in
machine.config file is affected on any application that runs on a particular
machine. Usually, this file is not altered and only web.config is used which
configuring applications.&lt;span style="font-family:Arial;"&gt; &lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-family:Arial;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;You can override settings in the Machine.Config file for all
the applications in a particular Web site by placing a Web.Config file in the
root directory of the Web site as follows:&lt;/p&gt;

&lt;p class="MsoNormal"&gt;\InetPub\wwwroot\Web.Config&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;/b&gt;
&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;a href="http://dng-config.blogspot.com/" title="Huge Collection of .Net FAQs"&gt;FAQ collected from http://dng-config.blogspot.com/&lt;/a&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;

&lt;h2&gt;&lt;span style="font-size:10pt;"&gt;What can be stored in Web.config&amp;nbsp;file?&lt;/span&gt;&lt;/h2&gt;

&lt;p&gt;&lt;span style="font-size:10pt;font-family:Arial;"&gt;There are number of
important settings that can be stored in the configuration file. Here are some
of the most frequently used configurations, stored conveniently inside
Web.config file..&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal" style="margin-right:0.5in;margin-left:1in;text-indent:-0.25in;"&gt;&lt;span&gt;1.&lt;span style="font-family:&amp;#39;Times New Roman&amp;#39;;font-style:normal;font-variant:normal;font-weight:normal;font-size:7pt;line-height:normal;font-size-adjust:none;font-stretch:normal;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:10pt;font-family:Arial;"&gt;Database connections.&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal" style="margin-right:0.5in;margin-left:1in;text-indent:-0.25in;"&gt;&lt;span&gt;2.&lt;span style="font-family:&amp;#39;Times New Roman&amp;#39;;font-style:normal;font-variant:normal;font-weight:normal;font-size:7pt;line-height:normal;font-size-adjust:none;font-stretch:normal;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:10pt;font-family:Arial;"&gt;Session States&lt;/span&gt; &lt;/p&gt;

&lt;p class="MsoNormal" style="margin-right:0.5in;margin-left:1in;text-indent:-0.25in;"&gt;&lt;span&gt;3.&lt;span style="font-family:&amp;#39;Times New Roman&amp;#39;;font-style:normal;font-variant:normal;font-weight:normal;font-size:7pt;line-height:normal;font-size-adjust:none;font-stretch:normal;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:10pt;font-family:Arial;"&gt;Error Handling&lt;/span&gt; (CustomError
Page Settings.)&lt;/p&gt;

&lt;p class="MsoNormal" style="margin-right:0.5in;margin-left:1in;text-indent:-0.25in;"&gt;&lt;span&gt;4.&lt;span style="font-family:&amp;#39;Times New Roman&amp;#39;;font-style:normal;font-variant:normal;font-weight:normal;font-size:7pt;line-height:normal;font-size-adjust:none;font-stretch:normal;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:10pt;font-family:Arial;"&gt;Security&lt;/span&gt; (Authentication
modes)&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;

&lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;/b&gt;
&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;a href="http://dng-config.blogspot.com/" title="Huge Collection of .Net FAQs"&gt;FAQ collected from http://dng-config.blogspot.com/&lt;/a&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;b&gt;What is the best place to store Database connection
string?&lt;/b&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;In Web.Config, you would add a key to the AppSettings
Section: &lt;/p&gt;

&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&amp;lt;appSettings&amp;gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&amp;lt;add key=&amp;quot;MyDBConnection&amp;quot; value=&amp;quot;data
source=&amp;lt;ServerName&amp;gt;;Initial catalog =&amp;lt;DBName&amp;gt;;user
id=&amp;lt;Username&amp;gt;;password=&amp;lt;Password&amp;gt;;&amp;quot; /&amp;gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&amp;lt;/appSettings&amp;gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;Example:&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&amp;lt;add key=&amp;quot;ConnectionString&amp;quot; value= &amp;quot;data
source=localhost;Initial catalog=northwind;user id=sa;password=mypass&amp;quot;
/&amp;gt;&lt;/p&gt;

&lt;p&gt;Then, in your ASP.Net application - just refer to it like this: &lt;/p&gt;

&lt;p style="margin:5pt 0.5in;"&gt;&lt;span style="font-size:10pt;font-family:Arial;"&gt;using
System.Configuration;&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:5pt 0.5in;"&gt;&lt;span style="font-size:10pt;font-family:Arial;"&gt;string connectionString
= (string )ConfigurationSettings.AppSettings[&amp;quot;ConnectionString&amp;quot;];&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;h1&gt;Can I use IIS as an alternative way of configuring Custom error pages?&lt;/h1&gt;

&lt;p class="MsoNormal"&gt;Yes, you can. But the preferable way would be ASP.NET, as
the ASP.NET custom pages are configured in XML based web.config (application
configuration) file, resulting in easy (xcopy) deployment and management.&lt;/p&gt;

&lt;h1&gt;&lt;b&gt;&lt;/b&gt;
&lt;/h1&gt;&lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;a href="http://dng-config.blogspot.com/" title="Huge Collection of .Net FAQs"&gt;FAQ collected from http://dng-config.blogspot.com/&lt;/a&gt;&lt;/b&gt;&lt;/p&gt;
&lt;h1&gt;&amp;nbsp;&lt;/h1&gt;

&lt;h1&gt;Hierarchy of Configuration File&lt;/h1&gt;

&lt;p class="MsoNormal"&gt;Configuration files are arranged in hierarchy.&lt;span&gt;&amp;nbsp; &lt;/span&gt;Child &lt;span style="font-size:10pt;"&gt;Web.Config&lt;/span&gt;
files override configuration settings specified by their parents. This means
that you do not need to copy the complete contents of a parent &lt;span style="font-size:10pt;"&gt;Web.Config&lt;/span&gt; file when creating a &lt;span style="font-size:10pt;"&gt;Web.Config&lt;/span&gt; lower in the hierarchy. You can
specify only the configuration settings that you need to modify.&lt;span&gt;&amp;nbsp; &lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;Note:&lt;span&gt;&amp;nbsp; &lt;/span&gt;If your asp.net
application doesn’t consist of Web.Config file than all the settings from
machine.config file would be applied.&lt;span&gt;&amp;nbsp; &lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;/b&gt;
&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;a href="http://dng-config.blogspot.com/" title="Huge Collection of .Net FAQs"&gt;FAQ collected from http://dng-config.blogspot.com/&lt;/a&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;

&lt;h1&gt;Difference between Web.Config and Machine.Config File&lt;/h1&gt;

&lt;p&gt;&lt;span style="font-size:9pt;font-family:Arial;color:black;"&gt;Two types of
configuration files supported by ASP.Net.&lt;br /&gt;
Configuration files are used to control and manage the behavior of a web
application.&lt;br /&gt;
&lt;br /&gt;
i) Machine.config&lt;br /&gt;
ii)Web.config&lt;br /&gt;
&lt;br /&gt;
Difference between Machine.Config and Web.Config&lt;br /&gt;
&lt;b&gt;Machine.Config:&lt;br /&gt;&lt;/b&gt;i) &amp;nbsp;This is automatically installed when you install Visual Studio. Net.&lt;br /&gt;
ii) This is also called machine level configuration file.&lt;br /&gt;
iii)Only one machine.config file exists on a server.&lt;br /&gt;
iv) This file is at the highest level in the configuration hierarchy.&lt;br /&gt;
&lt;br /&gt;&lt;b&gt;
Web.Config:&lt;br /&gt;&lt;/b&gt;i) &amp;nbsp;This is automatically created when you create an ASP.Net web
application project.&lt;br /&gt;
ii) This is also called application level configuration file.&lt;br /&gt;
iii)This file inherits setting from the machine.config&lt;/span&gt;&lt;b&gt;&lt;u&gt;&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;b&gt;Collect Most Updated FAQs @ &lt;a href="http://dng-config.blogspot.com/" title="Huge collection of .Net FAQs"&gt;http://dng-config.blogspot.com/&lt;/a&gt;&lt;/b&gt;&lt;br /&gt;&amp;nbsp;&lt;/p&gt;</description></item></channel></rss>