Friday, February 5, 2010

What is web.config file?

It is an XML file with the .config extension. As we have been developing ASP.NET applications, one of the files automatically generated is a little web.config file with information about the web site’s environment.  It contains all kinds of information related to web site. For example, that our by which version of .NET our application has been developed. However, the most basic web.config file is one that comes up in an error message that reads as follows:
<!-- Web.config Configuration File -->
<configuration>
<system.web>
<customErrors mode="Off"/>
</system.web>
</configuration>
We can use multiple web.config files. When we want users to have access to some files and not others, one way to control access is to use multiple web.config files. A web.config file in the root directory affects all of the files, but if we place a different web.config file in subdirectory, it will override the root web.config file.
For example, suppose we have the following directory structure:
Root (web.config)
    ASPNET
        Display
        Dreamer
        MapFile
        Special
            Lists(web.config)
All of the files and folders in the root directory are subject to the directives in the root web.config tile. However, in the Special directory is another web.config file that is open to all users:
<configuration>
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</configuration>
The <allow> node indicates which users have access, and the asterisk (*) is an “all” wildcard symbol.

No comments:

Post a Comment