diff --git a/.github/workflows/aspnetcore.yml b/.github/workflows/aspnetcore.yml
index 751593c2b..add9565bc 100644
--- a/.github/workflows/aspnetcore.yml
+++ b/.github/workflows/aspnetcore.yml
@@ -12,7 +12,7 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v4
with:
- dotnet-version: 8.0.x
+ dotnet-version: 9.0.x
- name: Restore
run: dotnet restore ./GrandNode.sln
- name: Build with dotnet
diff --git a/.github/workflows/grandnode.yml b/.github/workflows/grandnode.yml
index ee3a279ec..bfb14775b 100644
--- a/.github/workflows/grandnode.yml
+++ b/.github/workflows/grandnode.yml
@@ -17,7 +17,7 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v4
with:
- dotnet-version: 8.0.x
+ dotnet-version: 9.0.x
- name: Create mongoDB Docker container
run: sudo docker run -d -p 27017:27017 mongo:latest
- name: Restore
diff --git a/Directory.Packages.props b/Directory.Packages.props
index a190fbda9..de7acc506 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -1,67 +1,68 @@
-
- true
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Dockerfile b/Dockerfile
index 89a2d9c4b..415043435 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,5 +1,5 @@
# Build stage
-FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build-env
+FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build-env
LABEL stage=build-env
WORKDIR /app
@@ -24,7 +24,8 @@ RUN for plugin in /app/Plugins/*; do \
RUN dotnet publish /app/Web/Grand.Web/Grand.Web.csproj -c Release -o ./build/release -p:SourceRevisionId=$GIT_COMMIT -p:GitBranch=$GIT_BRANCH
# Runtime stage
-FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime
+FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS runtime
+
EXPOSE 8080
WORKDIR /app
COPY --from=build-env /app/build/release .
diff --git a/azure-pipelines.yml b/azure-pipelines.yml
index 3b000acd9..7ba85cf58 100644
--- a/azure-pipelines.yml
+++ b/azure-pipelines.yml
@@ -27,7 +27,7 @@ steps:
- task: UseDotNet@2
displayName: 'Install .NET Core SDK 8'
inputs:
- version: '8.0.x'
+ version: '9.0.x'
- task: NuGetToolInstaller@1
displayName: 'Install NuGet >=6.3.0-0'
diff --git a/global.json b/global.json
index 6c5cf46a5..41c9ad2ed 100644
--- a/global.json
+++ b/global.json
@@ -1,7 +1,7 @@
{
"sdk": {
- "version": "8.0.101",
+ "version": "9.0.100",
"rollForward": "latestFeature",
"allowPrerelease": false
}
-}
\ No newline at end of file
+}
diff --git a/src/Build/Grand.Common.props b/src/Build/Grand.Common.props
index 3e292e8ab..c950b7cab 100644
--- a/src/Build/Grand.Common.props
+++ b/src/Build/Grand.Common.props
@@ -1,6 +1,6 @@
- net8.0
+ net9.0
grandnode
diff --git a/src/Business/Grand.Business.Authentication/Startup/StartupApplication.cs b/src/Business/Grand.Business.Authentication/Startup/StartupApplication.cs
index 3cf110d00..59efd1205 100644
--- a/src/Business/Grand.Business.Authentication/Startup/StartupApplication.cs
+++ b/src/Business/Grand.Business.Authentication/Startup/StartupApplication.cs
@@ -21,8 +21,8 @@ public void ConfigureServices(IServiceCollection services, IConfiguration config
services.AddScoped();
}
- public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)
- {
+ public void Configure(WebApplication application, IWebHostEnvironment webHostEnvironment)
+ {
}
public int Priority => 100;
diff --git a/src/Business/Grand.Business.Catalog/Startup/StartupApplication.cs b/src/Business/Grand.Business.Catalog/Startup/StartupApplication.cs
index a530fa153..ad34e2d36 100644
--- a/src/Business/Grand.Business.Catalog/Startup/StartupApplication.cs
+++ b/src/Business/Grand.Business.Catalog/Startup/StartupApplication.cs
@@ -37,7 +37,7 @@ public void ConfigureServices(IServiceCollection services, IConfiguration config
RegisterExportImport(services);
}
- public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)
+ public void Configure(WebApplication application, IWebHostEnvironment webHostEnvironment)
{
}
diff --git a/src/Business/Grand.Business.Checkout/Startup/StartupApplication.cs b/src/Business/Grand.Business.Checkout/Startup/StartupApplication.cs
index b48043fb4..7e6ee4a2c 100644
--- a/src/Business/Grand.Business.Checkout/Startup/StartupApplication.cs
+++ b/src/Business/Grand.Business.Checkout/Startup/StartupApplication.cs
@@ -30,7 +30,7 @@ public void ConfigureServices(IServiceCollection services, IConfiguration config
RegisterExportImport(services);
}
- public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)
+ public void Configure(WebApplication application, IWebHostEnvironment webHostEnvironment)
{
}
diff --git a/src/Business/Grand.Business.Cms/Startup/StartupApplication.cs b/src/Business/Grand.Business.Cms/Startup/StartupApplication.cs
index 761a32c74..714aa4346 100644
--- a/src/Business/Grand.Business.Cms/Startup/StartupApplication.cs
+++ b/src/Business/Grand.Business.Cms/Startup/StartupApplication.cs
@@ -22,7 +22,7 @@ public void ConfigureServices(IServiceCollection services, IConfiguration config
services.AddScoped();
}
- public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)
+ public void Configure(WebApplication application, IWebHostEnvironment webHostEnvironment)
{
}
diff --git a/src/Business/Grand.Business.Common/Grand.Business.Common.csproj b/src/Business/Grand.Business.Common/Grand.Business.Common.csproj
index ab12e5942..5b649a90d 100644
--- a/src/Business/Grand.Business.Common/Grand.Business.Common.csproj
+++ b/src/Business/Grand.Business.Common/Grand.Business.Common.csproj
@@ -2,6 +2,7 @@
+
diff --git a/src/Business/Grand.Business.Common/Startup/StartupApplication.cs b/src/Business/Grand.Business.Common/Startup/StartupApplication.cs
index 8ee19bd76..824f9d488 100644
--- a/src/Business/Grand.Business.Common/Startup/StartupApplication.cs
+++ b/src/Business/Grand.Business.Common/Startup/StartupApplication.cs
@@ -39,7 +39,7 @@ public void ConfigureServices(IServiceCollection services, IConfiguration config
RegisterExportImportService(services);
}
- public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)
+ public void Configure(WebApplication application, IWebHostEnvironment webHostEnvironment)
{
}
diff --git a/src/Business/Grand.Business.Customers/Startup/StartupApplication.cs b/src/Business/Grand.Business.Customers/Startup/StartupApplication.cs
index 6014744c0..9179141ca 100644
--- a/src/Business/Grand.Business.Customers/Startup/StartupApplication.cs
+++ b/src/Business/Grand.Business.Customers/Startup/StartupApplication.cs
@@ -20,7 +20,7 @@ public void ConfigureServices(IServiceCollection services, IConfiguration config
RegisterCustomerService(services);
}
- public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)
+ public void Configure(WebApplication application, IWebHostEnvironment webHostEnvironment)
{
}
diff --git a/src/Business/Grand.Business.Marketing/Startup/StartupApplication.cs b/src/Business/Grand.Business.Marketing/Startup/StartupApplication.cs
index 70a329a3a..4caa13fe5 100644
--- a/src/Business/Grand.Business.Marketing/Startup/StartupApplication.cs
+++ b/src/Business/Grand.Business.Marketing/Startup/StartupApplication.cs
@@ -30,7 +30,7 @@ public void ConfigureServices(IServiceCollection services, IConfiguration config
RegisterCustomer(services);
}
- public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)
+ public void Configure(WebApplication application, IWebHostEnvironment webHostEnvironment)
{
}
diff --git a/src/Business/Grand.Business.Messages/Startup/StartupApplication.cs b/src/Business/Grand.Business.Messages/Startup/StartupApplication.cs
index 2c9a942d6..adf4cd445 100644
--- a/src/Business/Grand.Business.Messages/Startup/StartupApplication.cs
+++ b/src/Business/Grand.Business.Messages/Startup/StartupApplication.cs
@@ -26,7 +26,7 @@ public void ConfigureServices(IServiceCollection services, IConfiguration config
});
}
- public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)
+ public void Configure(WebApplication application, IWebHostEnvironment webHostEnvironment)
{
}
diff --git a/src/Business/Grand.Business.Storage/Startup/StartupApplication.cs b/src/Business/Grand.Business.Storage/Startup/StartupApplication.cs
index ea9e503db..7efcf882a 100644
--- a/src/Business/Grand.Business.Storage/Startup/StartupApplication.cs
+++ b/src/Business/Grand.Business.Storage/Startup/StartupApplication.cs
@@ -48,7 +48,7 @@ public void ConfigureServices(IServiceCollection services, IConfiguration config
});
}
- public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)
+ public void Configure(WebApplication application, IWebHostEnvironment webHostEnvironment)
{
}
diff --git a/src/Core/Grand.Infrastructure/IStartupApplication.cs b/src/Core/Grand.Infrastructure/IStartupApplication.cs
index 97ae79f52..d2f05ddf0 100644
--- a/src/Core/Grand.Infrastructure/IStartupApplication.cs
+++ b/src/Core/Grand.Infrastructure/IStartupApplication.cs
@@ -29,5 +29,5 @@ public interface IStartupApplication
///
/// Builder for configuring an application's request pipeline
/// WebHostEnvironment
- void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment);
+ void Configure(WebApplication application, IWebHostEnvironment webHostEnvironment);
}
\ No newline at end of file
diff --git a/src/Core/Grand.Infrastructure/Startup/StartupApplication.cs b/src/Core/Grand.Infrastructure/Startup/StartupApplication.cs
index 07cac0ad7..6ff52c510 100644
--- a/src/Core/Grand.Infrastructure/Startup/StartupApplication.cs
+++ b/src/Core/Grand.Infrastructure/Startup/StartupApplication.cs
@@ -18,7 +18,7 @@ public class StartupApplication : IStartupApplication
public bool BeforeConfigure => false;
- public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)
+ public void Configure(WebApplication application, IWebHostEnvironment webHostEnvironment)
{
}
diff --git a/src/Core/Grand.Infrastructure/StartupBase.cs b/src/Core/Grand.Infrastructure/StartupBase.cs
index 16da74a60..6e04b72f6 100644
--- a/src/Core/Grand.Infrastructure/StartupBase.cs
+++ b/src/Core/Grand.Infrastructure/StartupBase.cs
@@ -331,7 +331,7 @@ public static void ConfigureServices(IServiceCollection services, IConfiguration
///
/// Builder for configuring an application's request pipeline
/// WebHostEnvironment
- public static void ConfigureRequestPipeline(IApplicationBuilder application,
+ public static void ConfigureRequestPipeline(WebApplication application,
IWebHostEnvironment webHostEnvironment)
{
//find startup configurations provided by other assemblies
diff --git a/src/Modules/Grand.Module.Api/Infrastructure/ApiProviderStartup.cs b/src/Modules/Grand.Module.Api/Infrastructure/ApiProviderStartup.cs
index 272bf7d5b..87430c0dc 100644
--- a/src/Modules/Grand.Module.Api/Infrastructure/ApiProviderStartup.cs
+++ b/src/Modules/Grand.Module.Api/Infrastructure/ApiProviderStartup.cs
@@ -31,7 +31,7 @@ public void ConfigureServices(IServiceCollection services, IConfiguration config
///
/// Builder for configuring an application's request pipeline
/// WebHostEnvironment
- public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)
+ public void Configure(WebApplication application, IWebHostEnvironment webHostEnvironment)
{
}
diff --git a/src/Modules/Grand.Module.Api/Infrastructure/ODataStartup.cs b/src/Modules/Grand.Module.Api/Infrastructure/ODataStartup.cs
index 05bcdd7f1..208da7bca 100644
--- a/src/Modules/Grand.Module.Api/Infrastructure/ODataStartup.cs
+++ b/src/Modules/Grand.Module.Api/Infrastructure/ODataStartup.cs
@@ -33,9 +33,9 @@ namespace Grand.Module.Api.Infrastructure;
public class ODataStartup : IStartupApplication
{
- public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)
+ public void Configure(WebApplication application, IWebHostEnvironment webHostEnvironment)
{
- var apiConfig = application.ApplicationServices.GetService();
+ var apiConfig = application.Services.GetService();
if (apiConfig.Enabled) application.UseCors(Configurations.CorsPolicyName);
}
diff --git a/src/Modules/Grand.Module.Api/Infrastructure/SwaggerStartup.cs b/src/Modules/Grand.Module.Api/Infrastructure/SwaggerStartup.cs
index 3f49fca5b..a7ec1e541 100644
--- a/src/Modules/Grand.Module.Api/Infrastructure/SwaggerStartup.cs
+++ b/src/Modules/Grand.Module.Api/Infrastructure/SwaggerStartup.cs
@@ -14,11 +14,11 @@ namespace Grand.Module.Api.Infrastructure;
public class SwaggerStartup : IStartupApplication
{
- public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)
+ public void Configure(WebApplication application, IWebHostEnvironment webHostEnvironment)
{
- var backendApiConfig = application.ApplicationServices.GetService();
- var frontApiConfig = application.ApplicationServices.GetService();
- var swagger = application.ApplicationServices.GetService().GetValue("UseSwagger");
+ var backendApiConfig = application.Services.GetService();
+ var frontApiConfig = application.Services.GetService();
+ var swagger = application.Services.GetService().GetValue("UseSwagger");
if (backendApiConfig.Enabled)
application.UseODataQueryRequest();
diff --git a/src/Modules/Grand.Module.Installer/Startup/StartupApplication.cs b/src/Modules/Grand.Module.Installer/Startup/StartupApplication.cs
index 07608fb91..132744ee9 100644
--- a/src/Modules/Grand.Module.Installer/Startup/StartupApplication.cs
+++ b/src/Modules/Grand.Module.Installer/Startup/StartupApplication.cs
@@ -16,7 +16,7 @@ public void ConfigureServices(IServiceCollection services, IConfiguration config
RegisterInstallService(services);
}
- public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)
+ public void Configure(WebApplication application, IWebHostEnvironment webHostEnvironment)
{
}
diff --git a/src/Modules/Grand.Module.Migration/Startup/StartupApplication.cs b/src/Modules/Grand.Module.Migration/Startup/StartupApplication.cs
index 37eb1fca5..194a89e5b 100644
--- a/src/Modules/Grand.Module.Migration/Startup/StartupApplication.cs
+++ b/src/Modules/Grand.Module.Migration/Startup/StartupApplication.cs
@@ -17,16 +17,15 @@ public void ConfigureServices(IServiceCollection services, IConfiguration config
services.AddScoped();
}
- public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)
+ public void Configure(WebApplication application, IWebHostEnvironment webHostEnvironment)
{
if (!DataSettingsManager.DatabaseIsInstalled())
return;
- var serviceProvider = application.ApplicationServices;
- var featureFlagsConfig = serviceProvider.GetRequiredService();
+ var featureFlagsConfig = application.Services.GetRequiredService();
if (featureFlagsConfig.Modules.TryGetValue("Grand.Module.Migration", out var value) && value)
{
- var migrationProcess = serviceProvider.GetRequiredService();
+ var migrationProcess = application.Services.GetRequiredService();
migrationProcess.RunMigrationProcess();
}
}
diff --git a/src/Modules/Grand.Module.ScheduledTasks/Startup/StartupApplication.cs b/src/Modules/Grand.Module.ScheduledTasks/Startup/StartupApplication.cs
index cd0191149..d0741d68d 100644
--- a/src/Modules/Grand.Module.ScheduledTasks/Startup/StartupApplication.cs
+++ b/src/Modules/Grand.Module.ScheduledTasks/Startup/StartupApplication.cs
@@ -15,7 +15,7 @@ public void ConfigureServices(IServiceCollection services, IConfiguration config
RegisterTask(services);
}
- public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)
+ public void Configure(WebApplication application, IWebHostEnvironment webHostEnvironment)
{
}
diff --git a/src/Plugins/Authentication.Facebook/Authentication.Facebook.csproj b/src/Plugins/Authentication.Facebook/Authentication.Facebook.csproj
index 50944f72c..18bf655a4 100644
--- a/src/Plugins/Authentication.Facebook/Authentication.Facebook.csproj
+++ b/src/Plugins/Authentication.Facebook/Authentication.Facebook.csproj
@@ -20,7 +20,7 @@
-
+
diff --git a/src/Plugins/Authentication.Facebook/Infrastructure/StartupApplication.cs b/src/Plugins/Authentication.Facebook/Infrastructure/StartupApplication.cs
index 7805312ac..2952f7a46 100644
--- a/src/Plugins/Authentication.Facebook/Infrastructure/StartupApplication.cs
+++ b/src/Plugins/Authentication.Facebook/Infrastructure/StartupApplication.cs
@@ -16,7 +16,7 @@ public void ConfigureServices(IServiceCollection services, IConfiguration config
public int Priority => 10;
- public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)
+ public void Configure(WebApplication application, IWebHostEnvironment webHostEnvironment)
{
}
diff --git a/src/Plugins/Authentication.Google/Authentication.Google.csproj b/src/Plugins/Authentication.Google/Authentication.Google.csproj
index 52b894297..c98cfe0e2 100644
--- a/src/Plugins/Authentication.Google/Authentication.Google.csproj
+++ b/src/Plugins/Authentication.Google/Authentication.Google.csproj
@@ -19,7 +19,7 @@
-
+
diff --git a/src/Plugins/Authentication.Google/Infrastructure/StartupApplication.cs b/src/Plugins/Authentication.Google/Infrastructure/StartupApplication.cs
index 53cb41b09..91cf4de7b 100644
--- a/src/Plugins/Authentication.Google/Infrastructure/StartupApplication.cs
+++ b/src/Plugins/Authentication.Google/Infrastructure/StartupApplication.cs
@@ -16,7 +16,7 @@ public void ConfigureServices(IServiceCollection services, IConfiguration config
public int Priority => 10;
- public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)
+ public void Configure(WebApplication application, IWebHostEnvironment webHostEnvironment)
{
}
diff --git a/src/Plugins/DiscountRules.Standard/StartupApplication.cs b/src/Plugins/DiscountRules.Standard/StartupApplication.cs
index 718adfca7..f600e7b43 100644
--- a/src/Plugins/DiscountRules.Standard/StartupApplication.cs
+++ b/src/Plugins/DiscountRules.Standard/StartupApplication.cs
@@ -22,7 +22,7 @@ public void ConfigureServices(IServiceCollection services, IConfiguration config
public int Priority => 10;
- public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)
+ public void Configure(WebApplication application, IWebHostEnvironment webHostEnvironment)
{
}
diff --git a/src/Plugins/ExchangeRate.McExchange/StartupApplication.cs b/src/Plugins/ExchangeRate.McExchange/StartupApplication.cs
index 128cd7968..4e10fc3fa 100644
--- a/src/Plugins/ExchangeRate.McExchange/StartupApplication.cs
+++ b/src/Plugins/ExchangeRate.McExchange/StartupApplication.cs
@@ -16,7 +16,7 @@ public void ConfigureServices(IServiceCollection services, IConfiguration config
public int Priority => 10;
- public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)
+ public void Configure(WebApplication application, IWebHostEnvironment webHostEnvironment)
{
}
diff --git a/src/Plugins/Payments.BrainTree/Payments.BrainTree.csproj b/src/Plugins/Payments.BrainTree/Payments.BrainTree.csproj
index b0f0874b1..e05ebad1c 100644
--- a/src/Plugins/Payments.BrainTree/Payments.BrainTree.csproj
+++ b/src/Plugins/Payments.BrainTree/Payments.BrainTree.csproj
@@ -21,8 +21,8 @@
-
-
+
+
diff --git a/src/Plugins/Payments.BrainTree/StartupApplication.cs b/src/Plugins/Payments.BrainTree/StartupApplication.cs
index bcf458c5e..4bbe08021 100644
--- a/src/Plugins/Payments.BrainTree/StartupApplication.cs
+++ b/src/Plugins/Payments.BrainTree/StartupApplication.cs
@@ -18,7 +18,7 @@ public void ConfigureServices(IServiceCollection services, IConfiguration config
public int Priority => 10;
- public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)
+ public void Configure(WebApplication application, IWebHostEnvironment webHostEnvironment)
{
}
diff --git a/src/Plugins/Payments.CashOnDelivery/StartupApplication.cs b/src/Plugins/Payments.CashOnDelivery/StartupApplication.cs
index 33aa8f03c..8e41c793a 100644
--- a/src/Plugins/Payments.CashOnDelivery/StartupApplication.cs
+++ b/src/Plugins/Payments.CashOnDelivery/StartupApplication.cs
@@ -16,7 +16,7 @@ public void ConfigureServices(IServiceCollection services, IConfiguration config
public int Priority => 10;
- public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)
+ public void Configure(WebApplication application, IWebHostEnvironment webHostEnvironment)
{
}
diff --git a/src/Plugins/Payments.StripeCheckout/Payments.StripeCheckout.csproj b/src/Plugins/Payments.StripeCheckout/Payments.StripeCheckout.csproj
index 967d46688..8bd9f9c7c 100644
--- a/src/Plugins/Payments.StripeCheckout/Payments.StripeCheckout.csproj
+++ b/src/Plugins/Payments.StripeCheckout/Payments.StripeCheckout.csproj
@@ -20,7 +20,7 @@
-
+
diff --git a/src/Plugins/Payments.StripeCheckout/StartupApplication.cs b/src/Plugins/Payments.StripeCheckout/StartupApplication.cs
index d1706ab64..48488c937 100644
--- a/src/Plugins/Payments.StripeCheckout/StartupApplication.cs
+++ b/src/Plugins/Payments.StripeCheckout/StartupApplication.cs
@@ -18,7 +18,7 @@ public void ConfigureServices(IServiceCollection services, IConfiguration config
public int Priority => 10;
- public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)
+ public void Configure(WebApplication application, IWebHostEnvironment webHostEnvironment)
{
}
diff --git a/src/Plugins/Shipping.ByWeight/StartupApplication.cs b/src/Plugins/Shipping.ByWeight/StartupApplication.cs
index caf930020..af7a61a50 100644
--- a/src/Plugins/Shipping.ByWeight/StartupApplication.cs
+++ b/src/Plugins/Shipping.ByWeight/StartupApplication.cs
@@ -18,7 +18,7 @@ public void ConfigureServices(IServiceCollection services, IConfiguration config
public int Priority => 10;
- public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)
+ public void Configure(WebApplication application, IWebHostEnvironment webHostEnvironment)
{
}
diff --git a/src/Plugins/Shipping.FixedRateShipping/StartupApplication.cs b/src/Plugins/Shipping.FixedRateShipping/StartupApplication.cs
index 2b9ff384c..26f858cfa 100644
--- a/src/Plugins/Shipping.FixedRateShipping/StartupApplication.cs
+++ b/src/Plugins/Shipping.FixedRateShipping/StartupApplication.cs
@@ -16,7 +16,7 @@ public void ConfigureServices(IServiceCollection services, IConfiguration config
public int Priority => 10;
- public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)
+ public void Configure(WebApplication application, IWebHostEnvironment webHostEnvironment)
{
}
diff --git a/src/Plugins/Shipping.ShippingPoint/StartupApplication.cs b/src/Plugins/Shipping.ShippingPoint/StartupApplication.cs
index 5659d28b0..0d3ed2da1 100644
--- a/src/Plugins/Shipping.ShippingPoint/StartupApplication.cs
+++ b/src/Plugins/Shipping.ShippingPoint/StartupApplication.cs
@@ -18,7 +18,7 @@ public void ConfigureServices(IServiceCollection services, IConfiguration config
public int Priority => 10;
- public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)
+ public void Configure(WebApplication application, IWebHostEnvironment webHostEnvironment)
{
}
diff --git a/src/Plugins/Tax.CountryStateZip/StartupApplication.cs b/src/Plugins/Tax.CountryStateZip/StartupApplication.cs
index 321f8ac6f..7628d5ae9 100644
--- a/src/Plugins/Tax.CountryStateZip/StartupApplication.cs
+++ b/src/Plugins/Tax.CountryStateZip/StartupApplication.cs
@@ -18,7 +18,7 @@ public void ConfigureServices(IServiceCollection services, IConfiguration config
public int Priority => 20;
- public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)
+ public void Configure(WebApplication application, IWebHostEnvironment webHostEnvironment)
{
}
diff --git a/src/Plugins/Tax.FixedRate/StartupApplication.cs b/src/Plugins/Tax.FixedRate/StartupApplication.cs
index d803b83e0..1c9e2824b 100644
--- a/src/Plugins/Tax.FixedRate/StartupApplication.cs
+++ b/src/Plugins/Tax.FixedRate/StartupApplication.cs
@@ -16,7 +16,7 @@ public void ConfigureServices(IServiceCollection services, IConfiguration config
public int Priority => 10;
- public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)
+ public void Configure(WebApplication application, IWebHostEnvironment webHostEnvironment)
{
}
diff --git a/src/Plugins/Theme.Modern/StartupApplication.cs b/src/Plugins/Theme.Modern/StartupApplication.cs
index a362b7cd4..8c9f5c2cc 100644
--- a/src/Plugins/Theme.Modern/StartupApplication.cs
+++ b/src/Plugins/Theme.Modern/StartupApplication.cs
@@ -16,7 +16,7 @@ public void ConfigureServices(IServiceCollection services, IConfiguration config
public int Priority => 10;
- public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)
+ public void Configure(WebApplication application, IWebHostEnvironment webHostEnvironment)
{
}
diff --git a/src/Plugins/Widgets.FacebookPixel/StartupApplication.cs b/src/Plugins/Widgets.FacebookPixel/StartupApplication.cs
index df381b5c0..2a05fcbea 100644
--- a/src/Plugins/Widgets.FacebookPixel/StartupApplication.cs
+++ b/src/Plugins/Widgets.FacebookPixel/StartupApplication.cs
@@ -17,7 +17,7 @@ public void ConfigureServices(IServiceCollection services, IConfiguration config
public int Priority => 10;
- public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)
+ public void Configure(WebApplication application, IWebHostEnvironment webHostEnvironment)
{
}
diff --git a/src/Plugins/Widgets.GoogleAnalytics/StartupApplication.cs b/src/Plugins/Widgets.GoogleAnalytics/StartupApplication.cs
index 4e64f76bd..8591bab57 100644
--- a/src/Plugins/Widgets.GoogleAnalytics/StartupApplication.cs
+++ b/src/Plugins/Widgets.GoogleAnalytics/StartupApplication.cs
@@ -17,7 +17,7 @@ public void ConfigureServices(IServiceCollection services, IConfiguration config
public int Priority => 10;
- public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)
+ public void Configure(WebApplication application, IWebHostEnvironment webHostEnvironment)
{
}
diff --git a/src/Plugins/Widgets.Slider/StartupApplication.cs b/src/Plugins/Widgets.Slider/StartupApplication.cs
index fbe49b1c6..89f3722ad 100644
--- a/src/Plugins/Widgets.Slider/StartupApplication.cs
+++ b/src/Plugins/Widgets.Slider/StartupApplication.cs
@@ -18,7 +18,7 @@ public void ConfigureServices(IServiceCollection services, IConfiguration config
public int Priority => 10;
- public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)
+ public void Configure(WebApplication application, IWebHostEnvironment webHostEnvironment)
{
}
diff --git a/src/Tests/Grand.Data.Tests/MongoDb/CoreTestConfiguration.cs b/src/Tests/Grand.Data.Tests/MongoDb/CoreTestConfiguration.cs
index 9204a5e9a..4461b57e0 100644
--- a/src/Tests/Grand.Data.Tests/MongoDb/CoreTestConfiguration.cs
+++ b/src/Tests/Grand.Data.Tests/MongoDb/CoreTestConfiguration.cs
@@ -16,12 +16,9 @@
using MongoDB.Driver;
using MongoDB.Driver.Core.Clusters;
using MongoDB.Driver.Core.Configuration;
-using MongoDB.Driver.Core.Servers;
-using MongoDB.Driver.Core.WireProtocol.Messages.Encoders;
using NUnit.Framework;
using System.Diagnostics;
using System.Reflection;
-using System.Security.Cryptography.X509Certificates;
namespace Grand.Data.Tests.MongoDb;
@@ -68,23 +65,6 @@ public static ClusterBuilder ConfigureCluster(ClusterBuilder builder)
.ConfigureCluster(c =>
c.With(serverSelectionTimeout: TimeSpan.FromMilliseconds(int.Parse(serverSelectionTimeoutString))));
- if (ConnectionString.Tls.HasValue && ConnectionString.Tls.Value)
- {
- var certificateFilename = Environment.GetEnvironmentVariable("MONGO_SSL_CERT_FILE");
- if (certificateFilename != null)
- builder.ConfigureSsl(ssl =>
- {
- var password = Environment.GetEnvironmentVariable("MONGO_SSL_CERT_PASS");
- X509Certificate cert;
- if (password == null)
- cert = new X509Certificate2(certificateFilename);
- else
- cert = new X509Certificate2(certificateFilename, password);
- return ssl.With(
- clientCertificates: new[] { cert });
- });
- }
-
return ConfigureLogging(builder);
}
@@ -106,7 +86,7 @@ public static ICluster CreateCluster()
var hasWritableServer = 0;
var builder = ConfigureCluster();
var cluster = builder.BuildCluster();
-
+
if (TraceSource != null)
TraceSource.TraceEvent(TraceEventType.Information, 0, "CreateCluster: initializing cluster.");
diff --git a/src/Web/Grand.Web.Admin/Startup/StartupApplication.cs b/src/Web/Grand.Web.Admin/Startup/StartupApplication.cs
index e2c565488..1f9084504 100644
--- a/src/Web/Grand.Web.Admin/Startup/StartupApplication.cs
+++ b/src/Web/Grand.Web.Admin/Startup/StartupApplication.cs
@@ -62,7 +62,7 @@ public void ConfigureServices(IServiceCollection services, IConfiguration config
services.AddScoped();
}
- public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)
+ public void Configure(WebApplication application, IWebHostEnvironment webHostEnvironment)
{
}
diff --git a/src/Web/Grand.Web.Common/Binders/CustomAttributesBinder.cs b/src/Web/Grand.Web.Common/Binders/CustomAttributesBinder.cs
index 2e71b51d3..afa1d98f9 100644
--- a/src/Web/Grand.Web.Common/Binders/CustomAttributesBinder.cs
+++ b/src/Web/Grand.Web.Common/Binders/CustomAttributesBinder.cs
@@ -8,7 +8,7 @@ public class CustomAttributesBinder : IModelBinder
{
public Task BindModelAsync(ModelBindingContext bindingContext)
{
- if (bindingContext == null) throw new ArgumentNullException(nameof(bindingContext));
+ ArgumentNullException.ThrowIfNull(bindingContext);
if (bindingContext.HttpContext.Request.HasFormContentType)
{
diff --git a/src/Web/Grand.Web.Common/Infrastructure/ApplicationBuilderExtensions.cs b/src/Web/Grand.Web.Common/Infrastructure/ApplicationBuilderExtensions.cs
index 20dc168cf..afddf93f5 100644
--- a/src/Web/Grand.Web.Common/Infrastructure/ApplicationBuilderExtensions.cs
+++ b/src/Web/Grand.Web.Common/Infrastructure/ApplicationBuilderExtensions.cs
@@ -29,11 +29,10 @@ public static class ApplicationBuilderExtensions
/// Add exception handling
///
/// Builder for configuring an application's request pipeline
- public static void UseGrandExceptionHandler(this IApplicationBuilder application)
+ public static void UseGrandExceptionHandler(this WebApplication application)
{
- var serviceProvider = application.ApplicationServices;
- var appConfig = serviceProvider.GetRequiredService();
- var hostingEnvironment = serviceProvider.GetRequiredService();
+ var appConfig = application.Services.GetRequiredService();
+ var hostingEnvironment = application.Services.GetRequiredService();
var useDetailedExceptionPage = appConfig.DisplayFullErrorStack || hostingEnvironment.IsDevelopment();
if (useDetailedExceptionPage)
//get detailed exceptions for developing and testing purposes
@@ -83,7 +82,7 @@ public static void UseGrandExceptionHandler(this IApplicationBuilder application
/// Adds a special handler that checks for responses with the 404 status code that do not have a body
///
/// Builder for configuring an application's request pipeline
- public static void UsePageNotFound(this IApplicationBuilder application)
+ public static void UsePageNotFound(this WebApplication application)
{
application.UseStatusCodePages(async context =>
{
@@ -112,7 +111,7 @@ public static void UsePageNotFound(this IApplicationBuilder application)
/// Adds a special handler that checks for responses with the 400 status code (bad request)
///
/// Builder for configuring an application's request pipeline
- public static void UseBadRequestResult(this IApplicationBuilder application)
+ public static void UseBadRequestResult(this WebApplication application)
{
application.UseStatusCodePages(context =>
{
@@ -135,7 +134,7 @@ public static void UseBadRequestResult(this IApplicationBuilder application)
/// Configure authentication
///
/// Builder for configuring an application's request pipeline
- public static void UseGrandAuthentication(this IApplicationBuilder application)
+ public static void UseGrandAuthentication(this WebApplication application)
{
application.UseAuthentication();
application.UseAuthorization();
@@ -145,11 +144,11 @@ public static void UseGrandAuthentication(this IApplicationBuilder application)
/// Configure MVC endpoint
///
/// Builder for configuring an application's request pipeline
- public static void UseGrandEndpoints(this IApplicationBuilder application)
+ public static void UseGrandEndpoints(this WebApplication application)
{
application.UseEndpoints(endpoints =>
{
- var typeSearcher = endpoints.ServiceProvider.GetRequiredService();
+ var typeSearcher = application.Services.GetRequiredService();
var endpointProviders = typeSearcher.ClassesOfType();
var instances = endpointProviders
.Where(PluginExtensions.OnlyInstalledPlugins)
@@ -165,7 +164,7 @@ public static void UseGrandEndpoints(this IApplicationBuilder application)
/// Configure MVC endpoint
///
/// Builder for configuring an application's request pipeline
- public static void UseGrandDetection(this IApplicationBuilder application)
+ public static void UseGrandDetection(this WebApplication application)
{
application.UseDetection();
}
@@ -175,7 +174,7 @@ public static void UseGrandDetection(this IApplicationBuilder application)
///
/// Builder for configuring an application's request pipeline
/// AppConfig
- public static void UseGrandStaticFiles(this IApplicationBuilder application, AppConfig appConfig)
+ public static void UseGrandStaticFiles(this WebApplication application, AppConfig appConfig)
{
//static files
application.UseStaticFiles(new StaticFileOptions {
@@ -185,7 +184,7 @@ public static void UseGrandStaticFiles(this IApplicationBuilder application, App
ctx.Context.Response.Headers.Append(HeaderNames.CacheControl, appConfig.StaticFilesCacheControl);
}
});
- var webHostEnvironment = application.ApplicationServices.GetRequiredService();
+ var webHostEnvironment = application.Services.GetRequiredService();
var pluginsPath = Path.Combine(webHostEnvironment.ContentRootPath, CommonPath.Plugins);
//plugins
@@ -206,7 +205,7 @@ public static void UseGrandStaticFiles(this IApplicationBuilder application, App
/// Configure UseForwardedHeaders
///
/// Builder for configuring an application's request pipeline
- public static void UseGrandForwardedHeaders(this IApplicationBuilder application)
+ public static void UseGrandForwardedHeaders(this WebApplication application)
{
application.UseForwardedHeaders(new ForwardedHeadersOptions {
ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
@@ -217,7 +216,7 @@ public static void UseGrandForwardedHeaders(this IApplicationBuilder application
/// Configure Health checks
///
/// Builder for configuring an application's request pipeline
- public static void UseGrandHealthChecks(this IApplicationBuilder application)
+ public static void UseGrandHealthChecks(this WebApplication application)
{
application.UseHealthChecks("/health/live");
}
@@ -226,7 +225,7 @@ public static void UseGrandHealthChecks(this IApplicationBuilder application)
/// Configures the default security headers for your application.
///
/// Builder for configuring an application's request pipeline
- public static void UseDefaultSecurityHeaders(this IApplicationBuilder application)
+ public static void UseDefaultSecurityHeaders(this WebApplication application)
{
var policyCollection = new HeaderPolicyCollection()
.AddXssProtectionBlock()
@@ -273,7 +272,7 @@ public static void UseDefaultSecurityHeaders(this IApplicationBuilder applicatio
/// Configure middleware checking whether database is installed
///
/// Builder for configuring an application's request pipeline
- public static void UseInstallUrl(this IApplicationBuilder application)
+ public static void UseInstallUrl(this WebApplication application)
{
application.UseMiddleware();
}
@@ -282,7 +281,7 @@ public static void UseInstallUrl(this IApplicationBuilder application)
/// Configures whether use or not the Header X-Powered-By and its value.
///
/// Builder for configuring an application's request pipeline
- public static void UsePoweredBy(this IApplicationBuilder application)
+ public static void UsePoweredBy(this WebApplication application)
{
application.UseMiddleware();
}
diff --git a/src/Web/Grand.Web.Common/Startup/AuthenticationStartup.cs b/src/Web/Grand.Web.Common/Startup/AuthenticationStartup.cs
index c939421db..c0626ea0a 100644
--- a/src/Web/Grand.Web.Common/Startup/AuthenticationStartup.cs
+++ b/src/Web/Grand.Web.Common/Startup/AuthenticationStartup.cs
@@ -34,7 +34,7 @@ public void ConfigureServices(IServiceCollection services, IConfiguration config
///
/// Builder for configuring an application's request pipeline
/// WebHostEnvironment
- public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)
+ public void Configure(WebApplication application, IWebHostEnvironment webHostEnvironment)
{
//check whether database is installed
if (!DataSettingsManager.DatabaseIsInstalled())
diff --git a/src/Web/Grand.Web.Common/Startup/DbCheckStartup.cs b/src/Web/Grand.Web.Common/Startup/DbCheckStartup.cs
index 932fd97a3..d14c22645 100644
--- a/src/Web/Grand.Web.Common/Startup/DbCheckStartup.cs
+++ b/src/Web/Grand.Web.Common/Startup/DbCheckStartup.cs
@@ -14,13 +14,12 @@ public class DbCheckStartup : IStartupApplication
public int Priority => 0;
public bool BeforeConfigure => false;
- public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)
+ public void Configure(WebApplication application, IWebHostEnvironment webHostEnvironment)
{
if (!DataSettingsManager.DatabaseIsInstalled())
return;
- var serviceProvider = application.ApplicationServices;
- var performanceConfig = serviceProvider.GetRequiredService();
+ var performanceConfig = application.Services.GetRequiredService();
if (!performanceConfig.IgnoreDbVersionCheckMiddleware)
application.UseMiddleware();
diff --git a/src/Web/Grand.Web.Common/Startup/ErrorHandlerStartup.cs b/src/Web/Grand.Web.Common/Startup/ErrorHandlerStartup.cs
index 3f458c4d2..061d8b9c5 100644
--- a/src/Web/Grand.Web.Common/Startup/ErrorHandlerStartup.cs
+++ b/src/Web/Grand.Web.Common/Startup/ErrorHandlerStartup.cs
@@ -26,7 +26,7 @@ public void ConfigureServices(IServiceCollection services, IConfiguration config
///
/// Builder for configuring an application's request pipeline
/// WebHostEnvironment
- public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)
+ public void Configure(WebApplication application, IWebHostEnvironment webHostEnvironment)
{
//exception handling
application.UseGrandExceptionHandler();
diff --git a/src/Web/Grand.Web.Common/Startup/ForwardedHeadersStartup.cs b/src/Web/Grand.Web.Common/Startup/ForwardedHeadersStartup.cs
index 4253c4fa2..85fb94856 100644
--- a/src/Web/Grand.Web.Common/Startup/ForwardedHeadersStartup.cs
+++ b/src/Web/Grand.Web.Common/Startup/ForwardedHeadersStartup.cs
@@ -25,14 +25,13 @@ public void ConfigureServices(IServiceCollection services, IConfiguration config
///
/// Builder for configuring an application's request pipeline
/// WebHostEnvironment
- public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)
+ public void Configure(WebApplication application, IWebHostEnvironment webHostEnvironment)
{
//check whether database is installed
if (!DataSettingsManager.DatabaseIsInstalled())
return;
- var serviceProvider = application.ApplicationServices;
- var securityConfig = serviceProvider.GetRequiredService();
+ var securityConfig = application.Services.GetRequiredService();
if (securityConfig.ForceUseHTTPS)
application.Use((context, next) =>
{
diff --git a/src/Web/Grand.Web.Common/Startup/GrandCommonStartup.cs b/src/Web/Grand.Web.Common/Startup/GrandCommonStartup.cs
index 59bfc99e3..63e74597d 100644
--- a/src/Web/Grand.Web.Common/Startup/GrandCommonStartup.cs
+++ b/src/Web/Grand.Web.Common/Startup/GrandCommonStartup.cs
@@ -66,13 +66,12 @@ public void ConfigureServices(IServiceCollection services, IConfiguration config
///
/// Builder for configuring an application's request pipeline
/// WebHostEnvironment
- public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)
+ public void Configure(WebApplication application, IWebHostEnvironment webHostEnvironment)
{
- var serviceProvider = application.ApplicationServices;
- var appConfig = serviceProvider.GetRequiredService();
- var performanceConfig = serviceProvider.GetRequiredService();
- var securityConfig = serviceProvider.GetRequiredService();
- var featureFlagsConfig = serviceProvider.GetRequiredService();
+ var appConfig = application.Services.GetRequiredService();
+ var performanceConfig = application.Services.GetRequiredService();
+ var securityConfig = application.Services.GetRequiredService();
+ var featureFlagsConfig = application.Services.GetRequiredService();
//add HealthChecks
application.UseGrandHealthChecks();
diff --git a/src/Web/Grand.Web.Common/Startup/GrandMvcStartup.cs b/src/Web/Grand.Web.Common/Startup/GrandMvcStartup.cs
index 0c1b323e0..f88f03bca 100644
--- a/src/Web/Grand.Web.Common/Startup/GrandMvcStartup.cs
+++ b/src/Web/Grand.Web.Common/Startup/GrandMvcStartup.cs
@@ -34,7 +34,7 @@ public void ConfigureServices(IServiceCollection services, IConfiguration config
///
/// Builder for configuring an application's request pipeline
/// WebHostEnvironment
- public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)
+ public void Configure(WebApplication application, IWebHostEnvironment webHostEnvironment)
{
//endpoint routing
application.UseGrandEndpoints();
diff --git a/src/Web/Grand.Web.Common/Startup/HostFilteringStartup.cs b/src/Web/Grand.Web.Common/Startup/HostFilteringStartup.cs
index e51c6faf0..bac6dec16 100644
--- a/src/Web/Grand.Web.Common/Startup/HostFilteringStartup.cs
+++ b/src/Web/Grand.Web.Common/Startup/HostFilteringStartup.cs
@@ -35,7 +35,7 @@ public void ConfigureServices(IServiceCollection services, IConfiguration config
///
/// Builder for configuring an application's request pipeline
/// WebHostEnvironment
- public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)
+ public void Configure(WebApplication application, IWebHostEnvironment webHostEnvironment)
{
//check whether database is installed
if (!DataSettingsManager.DatabaseIsInstalled())
diff --git a/src/Web/Grand.Web.Common/Startup/LoggerStartup.cs b/src/Web/Grand.Web.Common/Startup/LoggerStartup.cs
index 6764092f5..fa862193b 100644
--- a/src/Web/Grand.Web.Common/Startup/LoggerStartup.cs
+++ b/src/Web/Grand.Web.Common/Startup/LoggerStartup.cs
@@ -28,13 +28,13 @@ public void ConfigureServices(IServiceCollection services, IConfiguration config
///
/// Builder for configuring an application's request pipeline
/// WebHostEnvironment
- public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)
+ public void Configure(WebApplication application, IWebHostEnvironment webHostEnvironment)
{
//check whether database is installed
if (!DataSettingsManager.DatabaseIsInstalled())
return;
- var appConfig = application.ApplicationServices.GetRequiredService();
+ var appConfig = application.Services.GetRequiredService();
//set context logging
if (appConfig.EnableContextLoggingMiddleware)
diff --git a/src/Web/Grand.Web.Common/Startup/StartupApplication.cs b/src/Web/Grand.Web.Common/Startup/StartupApplication.cs
index acf098ae9..61643d14d 100644
--- a/src/Web/Grand.Web.Common/Startup/StartupApplication.cs
+++ b/src/Web/Grand.Web.Common/Startup/StartupApplication.cs
@@ -47,7 +47,7 @@ public void ConfigureServices(IServiceCollection services, IConfiguration config
RegisterFramework(services);
}
- public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)
+ public void Configure(WebApplication application, IWebHostEnvironment webHostEnvironment)
{
}
diff --git a/src/Web/Grand.Web.Common/Startup/UrlRewriteStartup.cs b/src/Web/Grand.Web.Common/Startup/UrlRewriteStartup.cs
index ed49fbc2e..211406f74 100644
--- a/src/Web/Grand.Web.Common/Startup/UrlRewriteStartup.cs
+++ b/src/Web/Grand.Web.Common/Startup/UrlRewriteStartup.cs
@@ -13,6 +13,8 @@ namespace Grand.Web.Common.Startup;
///
public class UrlRewriteStartup : IStartupApplication
{
+ private const string UrlRewriteFilePath = "App_Data/UrlRewrite.xml";
+
///
/// Add and configure any of the middleware
///
@@ -27,37 +29,40 @@ public void ConfigureServices(IServiceCollection services, IConfiguration config
///
/// Builder for configuring an application's request pipeline
/// WebHostEnvironment
- public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)
+ public void Configure(WebApplication application, IWebHostEnvironment webHostEnvironment)
{
- var serviceProvider = application.ApplicationServices;
- var urlConfig = serviceProvider.GetRequiredService();
+ var urlConfig = application.Services.GetRequiredService();
var urlRewriteOptions = new RewriteOptions();
- var rewriteOptions = false;
- if (urlConfig.UseUrlRewrite)
- if (File.Exists("App_Data/UrlRewrite.xml"))
- {
- using var streamReader = File.OpenText("App_Data/UrlRewrite.xml");
- rewriteOptions = true;
- urlRewriteOptions.AddIISUrlRewrite(streamReader);
- }
+
+ ConfigureUrlRewriteOptions(urlRewriteOptions, urlConfig);
+ ConfigureHttpsOptions(urlRewriteOptions, urlConfig);
- if (urlConfig.UrlRewriteHttpsOptions)
+ if (urlRewriteOptions.Rules.Count > 0)
+ {
+ application.UseRewriter(urlRewriteOptions);
+ }
+ }
+ private void ConfigureUrlRewriteOptions(RewriteOptions options, UrlRewriteConfig config)
+ {
+ if (config.UseUrlRewrite && File.Exists(UrlRewriteFilePath))
{
- rewriteOptions = true;
- urlRewriteOptions.AddRedirectToHttps(urlConfig.UrlRewriteHttpsOptionsStatusCode,
- urlConfig.UrlRewriteHttpsOptionsPort);
+ using var streamReader = File.OpenText(UrlRewriteFilePath);
+ options.AddIISUrlRewrite(streamReader);
}
+ }
- if (urlConfig.UrlRedirectToHttpsPermanent)
+ private void ConfigureHttpsOptions(RewriteOptions options, UrlRewriteConfig config)
+ {
+ if (config.UrlRewriteHttpsOptions)
{
- rewriteOptions = true;
- urlRewriteOptions.AddRedirectToHttpsPermanent();
+ options.AddRedirectToHttps(config.UrlRewriteHttpsOptionsStatusCode, config.UrlRewriteHttpsOptionsPort);
}
- if (rewriteOptions)
- application.UseRewriter(urlRewriteOptions);
+ if (config.UrlRedirectToHttpsPermanent)
+ {
+ options.AddRedirectToHttpsPermanent();
+ }
}
-
///
/// Gets order of this startup configuration implementation
///
diff --git a/src/Web/Grand.Web.Vendor/Startup/StartupApplication.cs b/src/Web/Grand.Web.Vendor/Startup/StartupApplication.cs
index 86e255062..8eadd395e 100644
--- a/src/Web/Grand.Web.Vendor/Startup/StartupApplication.cs
+++ b/src/Web/Grand.Web.Vendor/Startup/StartupApplication.cs
@@ -23,7 +23,7 @@ public void ConfigureServices(IServiceCollection services, IConfiguration config
services.AddScoped();
}
- public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)
+ public void Configure(WebApplication application, IWebHostEnvironment webHostEnvironment)
{
}
diff --git a/src/Web/Grand.Web/Roslyn/UseForwardedHeaders.csx b/src/Web/Grand.Web/Roslyn/UseForwardedHeaders.csx
index d68e74d00..18a79157a 100644
--- a/src/Web/Grand.Web/Roslyn/UseForwardedHeaders.csx
+++ b/src/Web/Grand.Web/Roslyn/UseForwardedHeaders.csx
@@ -18,7 +18,7 @@ public class StartupApplication : IStartupApplication
public void ConfigureServices(IServiceCollection services, IConfiguration configuration)
{
}
- public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)
+ public void Configure(WebApplication application, IWebHostEnvironment webHostEnvironment)
{
var forwardedHeadersOptions = new ForwardedHeadersOptions
{