diff --git a/src/Datadog.Trace.ClrProfiler.Managed/Integrations/AspNet/AspNetMvcIntegration.cs b/src/Datadog.Trace.ClrProfiler.Managed/Integrations/AspNet/AspNetMvcIntegration.cs index 11fd634b749f..45311cbc4f22 100644 --- a/src/Datadog.Trace.ClrProfiler.Managed/Integrations/AspNet/AspNetMvcIntegration.cs +++ b/src/Datadog.Trace.ClrProfiler.Managed/Integrations/AspNet/AspNetMvcIntegration.cs @@ -80,8 +80,8 @@ public static Scope CreateScope(object controllerContext) if (route != null) { - var resourceUrl = route.Url.ToLowerInvariant(); - if (resourceUrl.First() != '/') + var resourceUrl = route.Url?.ToLowerInvariant() ?? string.Empty; + if (resourceUrl.FirstOrDefault() != '/') { resourceUrl = string.Concat("/", resourceUrl); }