devxlogo

Centralize ASP.NET settings in one file

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:

                                                        

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:

        

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.

devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist