Configure .NET Framework with web.config file
You can specify the configuration options in an application's web.config file or using YAML configuration. For the agent to pick up customized application settings with web.config, you must place these settings in the application web.config file's root configuration appSettings
section.
For example, two applications hosted in the same application pool will report as different servers if you configure the contrast.server.name
property in the appSettings
in each application's web.config file. Or, you could use web.config to configure the contrast.application.name
, like this:
<configuration> <appSettings> <add key="contrast.application.name" value="MyWebAppName" /> <add key="contrast.application.version" value="1.2.3" /> </appSettings> <system.web> ...
See the .NET Framework YAML template for a description of other available properties.
If your agent version is earlier than 21.1.4, only some properties can be configured with web.config as listed here.
Properties | Introduced with this .NET Framework agent version |
---|---|
| 19.6.3 |
| 19.1.3 |
| 19.1.3 |
| 19.1.3 |
| 20.6.6 |
| 20.6.6 |
| 19.1.3 |
| 19.1.3 |
| 19.1.3 |
| 19.1.3 |
Note
If contrast.application.name
is not specified, the .NET Framework agent will use the application's virtual path as an application name. If the application is hosted in the root of a site (meaning, the virtual path is /), the .NET Framework agent will use the site's name as the application name.
Important
Starting with agent version 21.1.4, users can set most agent configuration settings either with the application's web.config file or with a contrast_security.yaml
file in the same directory as the application. For example, two applications hosted in the same application pool can now report as different servers by setting contrast.server.name
in the appSettings
in each application's web.config file.
The following configuration settings are applied at the process level and cannot be customized separately for each application. You cannot set these properties using web.config and must set these configurations another way (like with YAML).
agent.dotnet.app_pool_denylist
agent.dotnet.app_pool_allowlist
agent.dotnet.enable_instrumentation_optimizations
agent.dotnet.enable_jit_inlining
agent.dotnet.enable_transparency_checks
agent.dotnet.enable_struct_dataflow
assess.enable_control_detection
Additionally, the agent's profiler component uses the process-level settings for the following keys, while the agent's sensor component will use the application-specific settings (if specified):
agent.logger.level
agent.logger.stdout