diff --git a/BTCPayServer/Components/Pager/Default.cshtml b/BTCPayServer/Components/Pager/Default.cshtml index 49244e705..571e5c647 100644 --- a/BTCPayServer/Components/Pager/Default.cshtml +++ b/BTCPayServer/Components/Pager/Default.cshtml @@ -1,3 +1,5 @@ +@using System.Web +@using BTCPayServer.TagHelpers @model BasePagingViewModel @{ @@ -85,10 +87,26 @@ { // merge both, preferring the `query` properties in case of duplicate keys query = query.Concat(Model.PaginationQuery) + .Where(e => e.Value != null) .GroupBy(e => e.Key) .ToDictionary(g => g.Key, g => g.First().Value); } - return Url.Action(null, query); + return ReplaceQueryParameters(query); + } + + string ReplaceQueryParameters(Dictionary query) + { + var uri = new Uri(ViewContext.HttpContext.Request.GetCurrentUrlWithQueryString()); + var queryParams = HttpUtility.ParseQueryString(uri.Query); + foreach (var (key, value) in query) + { + if (value != null) queryParams[key] = value?.ToString(); + } + var uriBuilder = new UriBuilder(uri) + { + Query = queryParams.ToString()! + }; + return uriBuilder.ToString(); } } diff --git a/BTCPayServer/Components/Pager/Pager.cs b/BTCPayServer/Components/Pager/Pager.cs index 9cb40cda5..abc6643e2 100644 --- a/BTCPayServer/Components/Pager/Pager.cs +++ b/BTCPayServer/Components/Pager/Pager.cs @@ -1,7 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; using BTCPayServer.Models; using Microsoft.AspNetCore.Mvc; diff --git a/BTCPayServer/Filters/DomainMappingConstraintAttribute.cs b/BTCPayServer/Filters/DomainMappingConstraintAttribute.cs index 52e9f5e6a..f918dadbb 100644 --- a/BTCPayServer/Filters/DomainMappingConstraintAttribute.cs +++ b/BTCPayServer/Filters/DomainMappingConstraintAttribute.cs @@ -46,6 +46,8 @@ namespace BTCPayServer.Filters var uri = new UriBuilder(req.Scheme, redirectDomain); if (req.Host.Port.HasValue) uri.Port = req.Host.Port.Value; + if (req.QueryString.HasValue) + uri.Query = req.QueryString.Value!; context.RouteContext.HttpContext.Response.Redirect(uri.ToString()); } return true;