From 81f35da08b3648add65d13deae4fc587e0745d80 Mon Sep 17 00:00:00 2001 From: maliming Date: Wed, 6 Jul 2022 10:31:44 +0800 Subject: [PATCH] Add bool return value to `MultiTenancyMiddlewareErrorPageBuilder` decide to continue the pipeline. --- docs/en/Multi-Tenancy.md | 3 +++ .../MultiTenancy/AbpAspNetCoreMultiTenancyOptions.cs | 4 +++- .../Abp/AspNetCore/MultiTenancy/MultiTenancyMiddleware.cs | 8 +++++--- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/docs/en/Multi-Tenancy.md b/docs/en/Multi-Tenancy.md index 8b8480669f..c915009686 100644 --- a/docs/en/Multi-Tenancy.md +++ b/docs/en/Multi-Tenancy.md @@ -44,6 +44,9 @@ Configure(options => options.MultiTenancyMiddlewareErrorPageBuilder = async (context, exception) => { // Handle the exception. + + //return true to stop the pipeline false to continue. + return true; }; }); ``` diff --git a/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/AbpAspNetCoreMultiTenancyOptions.cs b/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/AbpAspNetCoreMultiTenancyOptions.cs index d3b66952ef..5c26b524bd 100644 --- a/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/AbpAspNetCoreMultiTenancyOptions.cs +++ b/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/AbpAspNetCoreMultiTenancyOptions.cs @@ -16,7 +16,7 @@ public class AbpAspNetCoreMultiTenancyOptions /// public string TenantKey { get; set; } - public Func MultiTenancyMiddlewareErrorPageBuilder { get; set; } + public Func> MultiTenancyMiddlewareErrorPageBuilder { get; set; } public AbpAspNetCoreMultiTenancyOptions() { @@ -44,6 +44,8 @@ public class AbpAspNetCoreMultiTenancyOptions // Note the 500 spaces are to work around an IE 'feature' await context.Response.WriteAsync(new string(' ', 500)); + + return true; }; } } diff --git a/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/MultiTenancyMiddleware.cs b/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/MultiTenancyMiddleware.cs index 9cd89272f4..8fc6a3995c 100644 --- a/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/MultiTenancyMiddleware.cs +++ b/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/MultiTenancyMiddleware.cs @@ -34,15 +34,17 @@ public class MultiTenancyMiddleware : IMiddleware, ITransientDependency public async Task InvokeAsync(HttpContext context, RequestDelegate next) { - TenantConfiguration tenant; + TenantConfiguration tenant = null; try { tenant = await _tenantConfigurationProvider.GetAsync(saveResolveResult: true); } catch (Exception e) { - await _options.MultiTenancyMiddlewareErrorPageBuilder(context, e); - return; + if (await _options.MultiTenancyMiddlewareErrorPageBuilder(context, e)) + { + return; + } } if (tenant?.Id != _currentTenant.Id)