Skip to content

Commit 8b734a5

Browse files
authored
fix: Handle empty Request.Path values in AspNetCore middleware wrapper. (#1704)
1 parent b644dfd commit 8b734a5

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/Agent/NewRelic/Agent/Extensions/Providers/Wrapper/AspNetCore/WrapPipelineMiddleware.cs

+7-5
Original file line numberDiff line numberDiff line change
@@ -157,13 +157,15 @@ private ISegment SetupSegment(ITransaction transaction, HttpContext context)
157157
private ITransaction SetupTransaction(HttpRequest request)
158158
{
159159
var path = request.Path.Value;
160-
path = "/".Equals(path) ? "ROOT" : path.Substring(1);
160+
161+
// if path is empty, consider it the same as /
162+
path = request.Path == PathString.Empty || path.Equals("/") ? "ROOT" : path.Substring(1);
161163

162164
var transaction = _agent.CreateTransaction(
163-
isWeb: true,
164-
category: EnumNameCache<WebTransactionType>.GetName(WebTransactionType.ASP),
165-
transactionDisplayName: path,
166-
doNotTrackAsUnitOfWork: true);
165+
isWeb: true,
166+
category: EnumNameCache<WebTransactionType>.GetName(WebTransactionType.ASP),
167+
transactionDisplayName: path,
168+
doNotTrackAsUnitOfWork: true);
167169

168170
transaction.SetRequestMethod(request.Method);
169171
transaction.SetUri(request.Path);

0 commit comments

Comments
 (0)