Skip to content

Commit

Permalink
fix: Handle empty Request.Path values in AspNetCore middleware wrappe…
Browse files Browse the repository at this point in the history
…r. (#1704)
  • Loading branch information
tippmar-nr committed Jun 9, 2023
1 parent b644dfd commit 8b734a5
Showing 1 changed file with 7 additions and 5 deletions.
Expand Up @@ -157,13 +157,15 @@ private ISegment SetupSegment(ITransaction transaction, HttpContext context)
private ITransaction SetupTransaction(HttpRequest request)
{
var path = request.Path.Value;
path = "/".Equals(path) ? "ROOT" : path.Substring(1);

// if path is empty, consider it the same as /
path = request.Path == PathString.Empty || path.Equals("/") ? "ROOT" : path.Substring(1);

var transaction = _agent.CreateTransaction(
isWeb: true,
category: EnumNameCache<WebTransactionType>.GetName(WebTransactionType.ASP),
transactionDisplayName: path,
doNotTrackAsUnitOfWork: true);
isWeb: true,
category: EnumNameCache<WebTransactionType>.GetName(WebTransactionType.ASP),
transactionDisplayName: path,
doNotTrackAsUnitOfWork: true);

transaction.SetRequestMethod(request.Method);
transaction.SetUri(request.Path);
Expand Down

0 comments on commit 8b734a5

Please sign in to comment.