diff --git a/BTCPayServer/Hosting/Startup.cs b/BTCPayServer/Hosting/Startup.cs index 716b375ee..6f490d46b 100644 --- a/BTCPayServer/Hosting/Startup.cs +++ b/BTCPayServer/Hosting/Startup.cs @@ -229,9 +229,6 @@ namespace BTCPayServer.Hosting { app.UseDeveloperExceptionPage(); } - - app.UseCors(); - var forwardingOptions = new ForwardedHeadersOptions() { ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto @@ -240,25 +237,39 @@ namespace BTCPayServer.Hosting forwardingOptions.KnownProxies.Clear(); forwardingOptions.ForwardedHeaders = ForwardedHeaders.All; app.UseForwardedHeaders(forwardingOptions); +#if !NETCOREAPP21 + app.UseRouting(); +#endif app.UseCors(); app.UsePayServer(); app.UseStaticFiles(); app.UseProviderStorage(options); app.UseAuthentication(); app.UseSession(); +#if NETCOREAPP21 app.UseSignalR(route => { AppHub.Register(route); PaymentRequestHub.Register(route); }); +#endif app.UseWebSockets(); app.UseStatusCodePages(); +#if NETCOREAPP21 app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); +#else + app.UseEndpoints(endpoints => + { + AppHub.Register(endpoints); + PaymentRequestHub.Register(endpoints); + endpoints.MapControllerRoute("default", "{controller=Home}/{action=Index}/{id?}"); + }); +#endif } } } diff --git a/BTCPayServer/PaymentRequest/PaymentRequestHub.cs b/BTCPayServer/PaymentRequest/PaymentRequestHub.cs index 9c8701478..d643110bd 100644 --- a/BTCPayServer/PaymentRequest/PaymentRequestHub.cs +++ b/BTCPayServer/PaymentRequest/PaymentRequestHub.cs @@ -14,6 +14,10 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.SignalR; using BTCPayServer.Data; using Microsoft.AspNetCore.Http; +#if !NETCOREAPP21 +using Microsoft.AspNetCore.Routing; +using Microsoft.AspNetCore.Builder; +#endif namespace BTCPayServer.PaymentRequest { @@ -85,7 +89,12 @@ namespace BTCPayServer.PaymentRequest { return request.GetRelativePathOrAbsolute("/payment-requests/hub"); } + +#if NETCOREAPP21 public static void Register(HubRouteBuilder route) +#else + public static void Register(IEndpointRouteBuilder route) +#endif { route.MapHub("/payment-requests/hub"); } diff --git a/BTCPayServer/Services/Apps/AppHub.cs b/BTCPayServer/Services/Apps/AppHub.cs index 4ea2eb98e..af455b31e 100644 --- a/BTCPayServer/Services/Apps/AppHub.cs +++ b/BTCPayServer/Services/Apps/AppHub.cs @@ -5,7 +5,10 @@ using BTCPayServer.Models.AppViewModels; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.SignalR; -using Microsoft.Extensions.DependencyInjection; +#if !NETCOREAPP21 +using Microsoft.AspNetCore.Routing; +using Microsoft.AspNetCore.Builder; +#endif namespace BTCPayServer.Services.Apps { @@ -67,9 +70,14 @@ namespace BTCPayServer.Services.Apps { return request.GetRelativePathOrAbsolute("/apps/hub"); } +#if NETCOREAPP21 public static void Register(HubRouteBuilder route) +#else + public static void Register(IEndpointRouteBuilder route) +#endif { route.MapHub("/apps/hub"); } + } } diff --git a/BTCPayServer/Services/PaymentRequests/PaymentRequestRepository.cs b/BTCPayServer/Services/PaymentRequests/PaymentRequestRepository.cs index e263e1e7e..b103fb5c8 100644 --- a/BTCPayServer/Services/PaymentRequests/PaymentRequestRepository.cs +++ b/BTCPayServer/Services/PaymentRequests/PaymentRequestRepository.cs @@ -7,7 +7,6 @@ using BTCPayServer.Data; using BTCPayServer.Services.Invoices; using BTCPayServer.Services.Stores; using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Internal; namespace BTCPayServer.Services.PaymentRequests { @@ -133,7 +132,7 @@ namespace BTCPayServer.Services.PaymentRequests { using (var context = _ContextFactory.CreateContext()) { - var canDelete = !EnumerableExtensions.Any((await GetInvoicesForPaymentRequest(id))); + var canDelete = !(await GetInvoicesForPaymentRequest(id)).Any(); if (!canDelete) return false; var pr = await FindPaymentRequest(id, userId); if (pr == null)