You can lock configuration settings in ASP.NET configuration files (Web.config files) by adding an allowOverride attribute to a location element and setting the allowOverride attribute to false. Then within the location element, you can define the configuration section that you want to lock. ASP.NET will throw an exception if another configuration file attempts to override any configuration section that is defined within this locked location element.
Using a location element with an allowOverride=false attribute locks the entire configuration section. You can also lock individual configuration elements and attributes using lockItem, lockElements, lockAttributes, lockAllAttributesExcept, and lockAllElementsExcept.
Example:
The following code example shows part of a Web.config file that locks the trust level of two different ASP.NET applications: application1 and application2. Any attempt to override the configuration settings in the trust configuration section raises a configuration system error.
Code Snippet
- <configuration>
- <location path="application1" allowOverride="false">
- <system.web>
- <trust level="High" />
- </system.web>
- </location>
- <location path="application2" allowOverride="false">
- <system.web>
- <trust level="Medium" />
- </system.web>
- </location>
- </configuration>
End of Code Snippet
No comments:
Post a Comment