Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: VB7,C#
Expertise: Intermediate
Aug 24, 2002



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Centralize ASP.NET settings in one file

Although ASP.NET lets you distribute web.config files over all the application's subdirectories, it surely doesn't force you to do so. You can keep all the application settings in its main web.config file, while enforcing different settings on a directory-by-directory base, if you want. The key to this useful feature is the tag.

For example, let's see how an application's configuration file can specify different authorization settings for its different subdirectories. This web.config file enforces the same settings as the example seen in previous section:

      <allow roles="MyDomain\Administrator" />
      <deny users="*" />

  <location path="/Public">
        <allow users="?" />
You can use a tag also in machine.config to affect settings in individual ASP.NET applications and their subdirectories. In this case, the path attribute must begin with the IIS site name, as read in the MMC snap-in. For example, here's how you can enable tracing for the .aspx files in the /MyApp virtual directory of the default Web site:
<location path="Default Web Site/MyApp">
    <trace enabled="true" localOnly="true" pageOutput="true" />

This tips has been taken from Chapter 24 "ASP.NET Applications" of Francesco Balena's Programming Microsoft Visual Basic .NET (Microsoft Press). Read a sample chapter from our Book Bank, or buy at 30% off the list price.
Francesco Balena
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date