Browser monitoring and the .NET agent

With the .NET agent, you can add Browser monitoring 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.


This feature is not available for core applications whether they are monitored by the .NET Framework or Core agent.

Browser auto-instrumentation is enabled by default. With Browser auto-instrumentation, the .NET Framework agent automatically injects the Browser JavaScript header into any page that has a content-type of text/html and also has <head> tag within the page.

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 cache directory so that aspx pages are recompiled. Use the following command:


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.
.NET Web Forms view engine

When using .NET Web Forms view engine, be sure to use = and not :. That way the view engine will recognize the string of HTML returned from the API as HTML / JavaScript and render it appropriately.

If you are using .NET ASP Web Forms with master pages, add the header manually by calling GetBrowserTimingHeader() in your master page under the <head> tag:

<%= NewRelic.Api.Agent.NewRelic.GetBrowserTimingHeader() %>

Import the namespace with:

<%@ Import Namespace="NewRelic.Api.Agent" %>
Other view engines such as Razor

For other view engines such as Razor, you can use the GetBrowserTimingHeader() method to generate the header string. Here is a Razor-based view example:

<!DOCTYPE html>
<html lang="en">

When using .NET MVC, call the Html.Raw helper. That way, .NET MVC will recognize the string of HTML returned from the API as HTML / JavaScript and render it appropriately.

Disable instrumentation

To disable instrumentation:

Disable auto-instrumentation

To fully disable auto-instrumentation, edit newrelic.config and set the autoInstrument flag to false:

<!-- disable auto instrumentation -->
<browserMonitoring autoInstrument="false"/>

If you change the flag or uninstall the .NET agent, be sure to flush your cache again so that references to the agent are removed from compiled files.

Disable auto-instrumentation on a particular view

To disable only auto-instrumentation on a particular view, use the agent API call DisableBrowserMonitoring(). Add this call in any view where Browser scripts are not needed or wanted. Put this API call as close as possible to the top of the view where you want it disabled.

Disable both automatic and manual instrumentation on a particular view

To disable both auto-instrumentation and manual instrumentation for individual webpages, use the agent API call DisableBrowserMonitoring(true).


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

For more help

If you need more help, check out these support and learning resources: