diff --git a/BTCPayServer/Controllers/InvoiceController.UI.cs b/BTCPayServer/Controllers/InvoiceController.UI.cs index 1343d5f9b..5eb991cb2 100644 --- a/BTCPayServer/Controllers/InvoiceController.UI.cs +++ b/BTCPayServer/Controllers/InvoiceController.UI.cs @@ -19,6 +19,7 @@ using BTCPayServer.Security; using BTCPayServer.Services.Invoices; using BTCPayServer.Services.Invoices.Export; using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.EntityFrameworkCore.Internal; @@ -466,6 +467,10 @@ namespace BTCPayServer.Controllers [BitpayAPIConstraint(false)] public async Task ListInvoices(string searchTerm = null, int skip = 0, int count = 50) { + if (searchTerm == null) + { + searchTerm = HttpContext.Session.GetString("InvoicesSearchTerm"); + } var model = new InvoicesModel { SearchTerm = searchTerm, @@ -627,6 +632,14 @@ namespace BTCPayServer.Controllers [BitpayAPIConstraint(false)] public IActionResult SearchInvoice(InvoicesModel invoices) { + if (invoices.SearchTerm == null) + { + HttpContext.Session.Remove("InvoicesSearchTerm"); + } + else + { + HttpContext.Session.SetString("InvoicesSearchTerm", invoices.SearchTerm); + } return RedirectToAction(nameof(ListInvoices), new { searchTerm = invoices.SearchTerm, diff --git a/BTCPayServer/Hosting/Startup.cs b/BTCPayServer/Hosting/Startup.cs index 03e44478f..02340fd57 100644 --- a/BTCPayServer/Hosting/Startup.cs +++ b/BTCPayServer/Hosting/Startup.cs @@ -64,6 +64,7 @@ namespace BTCPayServer.Hosting .AddDefaultTokenProviders(); services.AddSignalR(); services.AddBTCPayServer(); + services.AddSession(); services.AddMvc(o => { o.Filters.Add(new XFrameOptionsAttribute("DENY")); @@ -169,6 +170,7 @@ namespace BTCPayServer.Hosting app.UsePayServer(); app.UseStaticFiles(); app.UseAuthentication(); + app.UseSession(); app.UseSignalR(route => { AppHub.Register(route);