Skip to content

Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.

Add new appsettings - IgnoreDbVersionCheckMiddleware

KrzysztofPajak7abd1e066d09
diff --git a/src/Core/Grand.Infrastructure/Configuration/AppConfig.cs b/src/Core/Grand.Infrastructure/Configuration/AppConfig.cs
index 4a57fda69..a1c5eb70b 100644
--- a/src/Core/Grand.Infrastructure/Configuration/AppConfig.cs
+++ b/src/Core/Grand.Infrastructure/Configuration/AppConfig.cs
@@ -239,6 +239,11 @@ namespace Grand.Infrastructure.Configuration
/// </summary>
public bool IgnoreInstallUrlMiddleware { get; set; }
+ /// <summary>
+ /// Gets or sets a value indicating whether ignore DbVersionCheckMiddleware
+ /// </summary>
+ public bool IgnoreDbVersionCheckMiddleware { get; set; }
+
/// <summary>
/// Gets or sets a value indicating whether ignore IgnoreUsePoweredByMiddleware
/// </summary>
diff --git a/src/Web/Grand.Web.Common/Startup/DbCheckStartup.cs b/src/Web/Grand.Web.Common/Startup/DbCheckStartup.cs
index 10fdc5996..096e4b0ac 100644
--- a/src/Web/Grand.Web.Common/Startup/DbCheckStartup.cs
+++ b/src/Web/Grand.Web.Common/Startup/DbCheckStartup.cs
@@ -1,5 +1,6 @@
using Grand.Domain.Data;
using Grand.Infrastructure;
+using Grand.Infrastructure.Configuration;
using Grand.Web.Common.Middleware;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
@@ -10,15 +11,19 @@ namespace Grand.Web.Common.Startup
{
public class DbCheckStartup : IStartupApplication
{
- public int Priority => -1000;
- public bool BeforeConfigure => true;
+ public int Priority => 0;
+ public bool BeforeConfigure => false;
public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)
{
if (!DataSettingsManager.DatabaseIsInstalled())
return;
- application.UseMiddleware<DbVersionCheckMiddleware>();
+ var serviceProvider = application.ApplicationServices;
+ var appConfig = serviceProvider.GetRequiredService<AppConfig>();
+
+ if(!appConfig.IgnoreDbVersionCheckMiddleware)
+ application.UseMiddleware<DbVersionCheckMiddleware>();
}
public void ConfigureServices(IServiceCollection services, IConfiguration configuration)
diff --git a/src/Web/Grand.Web/App_Data/appsettings.json b/src/Web/Grand.Web/App_Data/appsettings.json
index 95b9584dd..0b375299a 100644
--- a/src/Web/Grand.Web/App_Data/appsettings.json
+++ b/src/Web/Grand.Web/App_Data/appsettings.json
@@ -153,6 +153,8 @@
"PluginShadowCopy": true,
//Indicates whether to ignore InstallUrlMiddleware
"IgnoreInstallUrlMiddleware": false,
+ //Indicates whether to ignore DbVersionCheckMiddleware
+ "IgnoreDbVersionCheckMiddleware": true,
//Indicates whether to ignore UsePoweredByMiddleware
"IgnoreUsePoweredByMiddleware": false,
//(Serilog) Request logging - The package includes middleware for smarter HTTP request logging.