• /
  • EnglishEspañol日本語한국어Português
  • Inicia sesiónComenzar ahora

Browser monitoring and the .NET agent

With the .NET agent, you can add instrumentation to your webpages. Before you use browser with your .NET agent, refer to the .NET agent release notes, and make sure you have the installed the latest .NET agent release.

Follow the .NET agent requirements to install browser monitoring. Then follow the procedures in this document to manually instrument the .NET agent.

Auto-instrumentation

Importante

Auto-instrumentation is only available for .NET Framework web apps and .NET Core v6.0 and later web apps. Auto-instrumentation is unavailable for ASP.NET Core v5.0 and earlier applications even if they're monitored by the .NET agent.

With browser auto-instrumentation, the .NET agent automatically injects the browser JavaScript header into any page that has a content-type of text/html and also has a <head> tag within the page. Browser auto-instrumentation is enabled by default for .NET Framework web apps but is disabled by default for .NET Core v6 and later web apps. See Enabling browser auto-instrumentation for .NET Core v6+ for further information.

The <head> tag search starts at the beginning of the DOM. The .NET agent injects the JavaScript header through the addition of an HttpModule that modifies the page using HTTP response filters before streaming the content to the user.

The first time you enable auto-instrumentation, you may need to clean your asp.net cache directory so that aspx pages are recompiled. Use the following command:

bash
$
flush_dotnet_temp.cmd

With this injection, previously functioning pages may stop working if a content-type is not set correctly. To correct, review and update the content-types in your app or disable auto-instrumentation.

Manual instrumentation via agent API

If you cannot enable auto-instrumentation, you can still include the browser agent manually by using the New Relic .NET agent API and including appropriate code in your pages.

  1. To download the NewRelic.Api.Agent.dll, re-run the installation and reference the .dll:

    • From the New Relic .NET agent directory, select the New Relic.Net agent section, then select API Assembly.
    • NuGet: Install and reference the .dll by running Install-package NewRelic.Agent.Api.
  2. To set up your web application to call the New Relic .NET agent API, add a reference to NewRelic.Api.Agent.dll to your project.

  3. Optional: If you are modifying the deployed application directory on the web server, copy NewRelic.Api.Agent.dll into the application's bin directory.

  4. Call the API in your <head> tag. If a meta-tag with the X-UA-COMPATIBLE http-equiv attribute exists, set it after that meta tag.

Manual instrumentation with copy/paste

When enabling browser monitoring, you can manually insert the JavaScript snippet into your app's webpages. The copy/paste option gives you control over the exact placement of our JavaScript snippet, which is required to monitor the webpage's performance. For instructions on enabling browser monitoring with copy/paste, refer to our Browser documentation.

Disable instrumentation

To disable instrumentation:

Troubleshooting

Follow the troubleshooting procedures if you are unable to view any browser timing data.

Enable browser auto-instrumentation for .NET Core v6+ web applications

To enable browser auto-instrumentation in .NET Core v6+ web apps (requires .NET agent v10.19.2 or later):

  1. Ensure that you've enabled auto-instrumentation globally by editing newrelic.config and setting the browserMonitoring autoInstrument flag to true:

    <!-- enable auto instrumentation globally -->
    <browserMonitoring autoInstrument="true"/>
  2. Enable auto-instrumentation for .NET Core 6+ web apps by editing newrelic.config and adding a new item in the appSettings section (or add the appSettings section if it doesn't exist) - Note that is not the same as the appSettings section in a web.config file:

    <!-- enable .NET Core 6+ instrumentation -->
    <appSettings>
    <add key="EnableAspNetCore6PlusBrowserInjection" value="true" />
    </appSettings>

We recommend thorough testing of this feature in a non-production environment to ensure compatibility with your web application. If you experience any issues with this feature, please contact us for support.

Copyright © 2024 New Relic Inc.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.