|
Configuration
Management in ASP.NET 2.0 - Part 1
One
new, important feature in
ASP.NET 2.0 is the ability to read/edit the configuration files in
local machine or remote machine. In ASP.NET
1.x, editing of the configuration files was not supported. Only option
to edit a configuration file is to treat the configuration file as an xml file
and update that xml file. The major drawback in this method is that you need to
treat all the sections in the configuration file as
XML Node, which is not strongly typed. Hence, you can do only string
manipulation to update any
configuration settings in that file. However, in
ASP.NET 2.0 you have strongly typed API’s to read/edit the
configuration files.
This article series describes the various options
available in ASP.NET 2.0 to
read/edit the configuration files. The various options available to read/edit
the configuration files are
-
Using
Web Site Administration Tool
-
Using
ASP.NET Microsoft Management Console(MMC)
-
Using
Configuration API’s
Using
Web Site Administration Tool
Web site Administration tool is a simple web interface for managing web
site configuration. This tool can be invoked using following two options
-
By selecting ASP.NET Configuration from Website menu option in VS.NET ( Website
à
ASP.NET Configuration)
-
By accessing webadmin.axd file from
root directory of any webapplication. For example,
http://localhost/webapplication1/webadmin.axd
Special HTTP Handler like trace.axd will handle webadmin.axd
file request. This handler will redirect the request to the Web site
Administration tool. Web site administration tool is installed along with
.NET Framework 2.0. By default, it is installed in IIS, root
directory/aspnet_webadmin/ 2_0_40607. Web site administration tool is shown in
the following figure.

Configuration settings for web site administration tool are
stored in machine.config file in <WebsiteAdministrationTool> section.
Sample configuration of websiteadministration tool is show below
<webSiteAdministrationTool defaultUrl=”/aspnet_webadmin/2_0_40607/default.aspx” physicalPath=”<anystring>” enabled=”[true|false]” localOnly=”[true|false]” > <categories> <category navigateUrl="default.aspx" title="Home" /> <category navigateUrl="security/security.aspx" title="Security" /> …. </categories>
Httphandler (webadmin.axd)
and VS.NET will pick the default URL setting from this section to open the web
site administration tool. If you want to allow users to access administration
site from remote machine, then you can set localOnly
attribute to true. Similarly, if you want to restrict certain users from
accessing administration site in your web server, then you can use
authorization section to mention that. Finally,
categories section is used to
mention about categories tab in administration tool. By
default, this tool has four tabs - security,
profile,
application and provider. If
you want to add new tab to this tool, then you need to register about that tab
in this section.
This tool can be used not only for editing
web.config file, but also for managing web site.
For example, you can use this tool
to create users and roles for a website and for managing profile values. When
you use this tool for this first time and if the configuration file does not
exist for that web application, then this tool will create a
web.config with default settings for that application. Along
with web.config file, this tool also
creates default site database, which is Access database (AspNetDB.mdb) in data
folder of that web application. This tool uses this database to store data like
users and roles. If the default provider is mentioned for this web application,
then this tool will use that database. It will not create a new database for
its use.
As mentioned early, this tool has four tabs
security, profile,
application and provider.
Application tab is used to manage
1.
Appsettings section in config file. You can add/modify appsetting name
value pairs
2.
SMPT settings
3.
Debugging and Tracing section in config file.
4.
Counter and site statistics tracking section in config file.
Security tab is
used to manage
1.
Authentication and Authorization settings in config file.
2.
For creating user and roles when authentication is forms authentication.
You can also map users to roles in this section.
Provider tab is
used to manage providers for that website. You can use this tab to create new
provider or for modifying existing provider settings.
Profile tab is used
to manage how the web site collects personal information. You can use this tab
to enable profile tracking for a website; you can also create new profile for a
website. You can use this tab to clean up the profile values for a web site.
You can view the various reports of profile data from this tab.
Note: In this beta
1 release, this reporting option is not supported. However, for final release,
it will be supported.
Conclusion
In first part of this article, we
discussed about Web site Administration tool. In the second part of this
article, we will discuss about ASP.NET Microsoft Management Console(MMC) and
Configuration API's.
|