Application configuration in ASP.NET - ASP.NET (2024)

  • Article

This article describes how to make application-specific and directory-specific configuration settings in ASP.NET.

Original product version: ASP.NET
Original KB number: 815174

Summary

The Web.config file is in the root directory of an ASP.NET application. The Web.config file specifies configuration information that is specific to the application. You can also set configuration settings on a per-directory basis. There are two ways to do so:

  • Distribute multiple Web.config files to directories in the application. Add a Web.config file in the ASP.NET application directory with settings that override settings in a higher-level Web.config file or in the system machine configuration (Machine.config) file.

  • Add per-directory or per-file settings directly to the application Web.config file. This method uses a single Web.config file to turn on per-directory configuration settings. You can also use this method in the Machine.config file to force configuration settings on ASP.NET web applications and then to stop Web.config files from overriding Machine.config settings.

Use the location element in the Machine.config file

To specify settings that apply to a web application or directory, you can add the <location> element to the <configuration> element of a system Machine.config file. It's useful when you centralize configuration settings in a single file. It's also useful in Web-hosting environments to mandate specific configuration settings on individual web applications.

The <location> element contains two attributes, path and allowOverride. The path attribute defines the site or virtual directory that the configuration settings cover. To specify that the settings in the <location> element apply to the default Web site, set the path attribute to Default Web Site. To specify that the settings apply to the application that is named MyApp in the default web site, set the path attribute to Default Web Site/MyApp.

When the allowOverride attribute is false, the Web.config files in the web application directories can't override the settings that you specified in the <location> element. It's a useful setting in environments where you must restrict application developers in how they configure a web application. The following example shows a part of a Machine.config file. The file requires authentication to access the MyApp application on the default Web site and can't be overridden by settings in a Web.config file.

<configuration> <location path="Default Web Site/MyApp" allowOverride="false"> <system.web> <authorization> <allow users="?" /> </authorization> </system.web> </location></configuration>

Use the location element in the Web.config file

To specify settings that apply to a specific application or directory, add the <location> element to the <configuration> element of an application Web.config file. The <location> element typically contains a <system.web> element and other configuration elements exactly as you use them in the Web.config file. The path attribute of the <location> element specifies the virtual directory or the file name where the location configuration items apply. The following example shows part of an application Web.config file that specifies custom error messages for the forum virtual directory.

<configuration> <location path="forum" > <system.web> <customErrors mode="RemoteOnly" defaultRedirect="forum-error.aspx"> <error statusCode="404" redirect="forum-file-not-found.aspx" /> </customErrors> </system.web> </location></configuration>

References

Application configuration in ASP.NET - ASP.NET (2024)
Top Articles
Sushi Rice Made in Bamboo Steamer Recipe - Food.com
A Guide to Testing Mobile CPU & GPU Performance
Cpmc Mission Bernal Campus & Orthopedic Institute Photos
CLI Book 3: Cisco Secure Firewall ASA VPN CLI Configuration Guide, 9.22 - General VPN Parameters [Cisco Secure Firewall ASA]
Guardians Of The Galaxy Showtimes Near Athol Cinemas 8
Coffman Memorial Union | U of M Bookstores
Tv Guide Bay Area No Cable
Dee Dee Blanchard Crime Scene Photos
How Much Is 10000 Nickels
The Pope's Exorcist Showtimes Near Cinemark Hollywood Movies 20
AB Solutions Portal | Login
Geometry Escape Challenge A Answer Key
Robot or human?
Zendaya Boob Job
Knaben Pirate Download
10 Free Employee Handbook Templates in Word & ClickUp
Magic Mike's Last Dance Showtimes Near Marcus Cedar Creek Cinema
Eva Mastromatteo Erie Pa
Rams vs. Lions highlights: Detroit defeats Los Angeles 26-20 in overtime thriller
Niche Crime Rate
PowerXL Smokeless Grill- Elektrische Grill - Rookloos & geurloos grillplezier - met... | bol
Jenna Ortega’s Height, Age, Net Worth & Biography
Dewalt vs Milwaukee: Comparing Top Power Tool Brands - EXTOL
Cookie Clicker Advanced Method Unblocked
Hannah Palmer Listal
Wsbtv Fish And Game Report
11526 Lake Ave Cleveland Oh 44102
Claio Rotisserie Menu
Skidware Project Mugetsu
Gncc Live Timing And Scoring
Die wichtigsten E-Nummern
Kacey King Ranch
Primerica Shareholder Account
Promatch Parts
Swimgs Yuzzle Wuzzle Yups Wits Sadie Plant Tune 3 Tabs Winnie The Pooh Halloween Bob The Builder Christmas Autumns Cow Dog Pig Tim Cook’s Birthday Buff Work It Out Wombats Pineview Playtime Chronicles Day Of The Dead The Alpha Baa Baa Twinkle
Melissa N. Comics
3 Bedroom 1 Bath House For Sale
Jefferson Parish Dump Wall Blvd
Wsbtv Fish And Game Report
Puffco Peak 3 Red Flashes
Studentvue Columbia Heights
Ghareeb Nawaz Texas Menu
Patricia And Aaron Toro
Southwest Airlines Departures Atlanta
Avance Primary Care Morrisville
Top 1,000 Girl Names for Your Baby Girl in 2024 | Pampers
Matt Brickman Wikipedia
Unpleasant Realities Nyt
Raley Scrubs - Midtown
Chitterlings (Chitlins)
Latest Posts
Article information

Author: Ouida Strosin DO

Last Updated:

Views: 6039

Rating: 4.6 / 5 (56 voted)

Reviews: 95% of readers found this page helpful

Author information

Name: Ouida Strosin DO

Birthday: 1995-04-27

Address: Suite 927 930 Kilback Radial, Candidaville, TN 87795

Phone: +8561498978366

Job: Legacy Manufacturing Specialist

Hobby: Singing, Mountain biking, Water sports, Water sports, Taxidermy, Polo, Pet

Introduction: My name is Ouida Strosin DO, I am a precious, combative, spotless, modern, spotless, beautiful, precious person who loves writing and wants to share my knowledge and understanding with you.