From 81abc975091469b150923998b29f111c296884b5 Mon Sep 17 00:00:00 2001 From: James Griffiths Date: Tue, 12 Nov 2024 17:50:26 +0000 Subject: [PATCH] EHD-1411: Reduce code in Core project: Fix bug (Google Analytics Tracker) --- GenderPayGap.WebUI/Classes/GoogleAnalyticsTracker.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/GenderPayGap.WebUI/Classes/GoogleAnalyticsTracker.cs b/GenderPayGap.WebUI/Classes/GoogleAnalyticsTracker.cs index 648b6d0d8..6754b4c96 100644 --- a/GenderPayGap.WebUI/Classes/GoogleAnalyticsTracker.cs +++ b/GenderPayGap.WebUI/Classes/GoogleAnalyticsTracker.cs @@ -3,6 +3,7 @@ using System.Net; using System.Net.Http; using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Extensions; using Microsoft.AspNetCore.Mvc; using Polly; using Polly.Extensions.Http; @@ -61,11 +62,11 @@ public void TrackPageView(Controller controller, string pageTitle = null, string if (string.IsNullOrWhiteSpace(pageUrl)) { - pageUrl = $"{controller.HttpContext.Request.Path}{controller.HttpContext.Request.QueryString}"; + pageUrl = controller.HttpContext.Request.GetDisplayUrl(); } else if (!IsUrl(pageUrl)) { - pageUrl = RelativeToAbsoluteUrl(pageUrl, new Uri($"{controller.HttpContext.Request.Path}{controller.HttpContext.Request.QueryString}")); + pageUrl = RelativeToAbsoluteUrl(pageUrl, new Uri(controller.HttpContext.Request.GetDisplayUrl())); } SendPageViewTracking(pageTitle, pageUrl);