---
title: Missing .NET async metrics
source: https://docs.newrelic.com/docs/apm/agents/net-agent/troubleshooting/missing-net-async-metrics
---

## Problem

You do not see [async transactions](https://docs.newrelic.com/docs/agents/net-agent/additional-installation/async-support-net) for `WebApi`, `HttpClient`, `SqlCommand`, `SqlDataReader`, `NpgsqlCommand`, or custom instrumentation. This problem typically occurs for apps created with [New Relic's .NET agent](https://docs.newrelic.com/docs/agents/net-agent/getting-started/compatibility-requirements-net-framework-agent#net-version) under .NET Framework 4.0 or earlier, then migrated to .NET Framework 4.5 or higher.

## Solution

### Upgrade appSetting for pipeline [#appsetting]

A specific `appSetting` or `system.web` setting is required if you are using:

-   WebApi1 or WebApi2
-   Async methods in `HttpClient`, `SqlCommand`, `SqlDataReader`, or `NpgsqlCommand`
-   Async-related custom transactions or custom instrumentation
-   New Relic .NET agent version 5.11.53.0 or higher
-   .NET Framework 4.5 or higher as the target for your app

If these conditions apply, then you must ensure your app uses the upgraded request processing pipeline introduced in .NET 4.5.

To use the upgraded pipeline, ensure your `web.config` includes one of the following settings. If neither setting appears, add one:

**Recommended: Tell .NET to use the new pipeline**

Tell .NET to use the new ASP request processing pipeline:

````xml
<configuration>
  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
  </appSettings>
<configuration>
```

````

**Specify your target framework version**

If you want to specify the .NET Framework version you target, be aware that this imposes strict runtime checks that can cause compatibility issues. Recommendation: If possible, [tell .NET to use the new pipeline](#use-new-pipeline) instead of using this option.

The specified version of the .NET Framework must be installed on your machine, and it must be version 4.5.2 or higher:

````xml
<configuration>
  <system.web>
    <httpRuntime targetFramework="YOUR_TARGET_NET_VERSION" /> 
  </system.web>
<configuration>
```

````

### Recommended: Verify compatibility with the new pipeline [#enforce-async]

Optional: You can tell the .NET framework to perform additional checks of your async code at runtime. These checks catch common issues in async code, which may be masked by the legacy ASP pipeline.

If your app passes without any issues, you can be confident that your app correctly handles the new pipeline. For more information, see [Microsoft's configuration documentation](https://msdn.microsoft.com/en-us/library/hh975440%28v=vs.120%29.aspx?f=255&MSPPError=-2147217396).

To enforce additional checks, add the following to `web.config`:

```xml
<configuration>
  <appSettings>
    <add key="aspnet:AllowAsyncDuringSyncStages" value="false" />
  </appSettings>
<configuration>
```

## Cause

Async instrumentation is disabled if the legacy integrated pipeline is present. Before .NET 4.5, the integrated pipeline could cause deadlocks. For more information about this .NET Framework bug, see:

-   [Why is `HttpContext.Current` null after await?](https://stackoverflow.com/questions/18383923/why-is-httpcontext-current-null-after-await)
-   [All about `<httpRuntime targetFramework>`](https://devblogs.microsoft.com/dotnet/all-about-httpruntime-targetframework/)
