diff --git a/Sanhe.Abp.Startup.sln b/Sanhe.Abp.Framework.sln
similarity index 100%
rename from Sanhe.Abp.Startup.sln
rename to Sanhe.Abp.Framework.sln
diff --git a/modules/mvc/Sanhe.Abp.AspNetCore.Mvc.Wrapper/Microsoft/AspNetCore/Cors/AbpCorsPolicyBuilderExtensions.cs b/modules/mvc/Sanhe.Abp.AspNetCore.Mvc.Wrapper/Microsoft/AspNetCore/Cors/AbpCorsPolicyBuilderExtensions.cs
new file mode 100644
index 0000000..026c593
--- /dev/null
+++ b/modules/mvc/Sanhe.Abp.AspNetCore.Mvc.Wrapper/Microsoft/AspNetCore/Cors/AbpCorsPolicyBuilderExtensions.cs
@@ -0,0 +1,15 @@
+using Microsoft.AspNetCore.Cors.Infrastructure;
+using Sanhe.Abp.Wrapper;
+
+namespace Microsoft.AspNetCore.Cors;
+
+public static class AbpCorsPolicyBuilderExtensions
+{
+ public static CorsPolicyBuilder WithAbpWrapExposedHeaders(this CorsPolicyBuilder corsPolicyBuilder)
+ {
+ return corsPolicyBuilder
+ .WithExposedHeaders(
+ AbpHttpWrapConsts.AbpWrapResult,
+ AbpHttpWrapConsts.AbpDontWrapResult);
+ }
+}
diff --git a/modules/mvc/Sanhe.Abp.AspNetCore.Mvc.Wrapper/Microsoft/AspNetCore/Mvc/ActionContextExtensions.cs b/modules/mvc/Sanhe.Abp.AspNetCore.Mvc.Wrapper/Microsoft/AspNetCore/Mvc/ActionContextExtensions.cs
new file mode 100644
index 0000000..9234dc5
--- /dev/null
+++ b/modules/mvc/Sanhe.Abp.AspNetCore.Mvc.Wrapper/Microsoft/AspNetCore/Mvc/ActionContextExtensions.cs
@@ -0,0 +1,27 @@
+using Microsoft.AspNetCore.Mvc.Abstractions;
+using Microsoft.AspNetCore.Mvc.Controllers;
+using Sanhe.Abp.Wrapper;
+
+namespace Microsoft.AspNetCore.Mvc;
+
+public static class ActionContextExtensions
+{
+ public static bool CanWarpRsult(this ActionDescriptor actionDescriptor)
+ {
+ if (actionDescriptor is ControllerActionDescriptor descriptor)
+ {
+ if (descriptor.MethodInfo.IsDefined(typeof(IgnoreWrapResultAttribute), true))
+ {
+ return false;
+ }
+
+ if (descriptor.ControllerTypeInfo.IsDefined(typeof(IgnoreWrapResultAttribute), true))
+ {
+ return false;
+ }
+
+ return true;
+ }
+ return false;
+ }
+}
diff --git a/modules/mvc/Sanhe.Abp.AspNetCore.Mvc.Wrapper/Sanhe.Abp.AspNetCore.Mvc.Wrapper.csproj b/modules/mvc/Sanhe.Abp.AspNetCore.Mvc.Wrapper/Sanhe.Abp.AspNetCore.Mvc.Wrapper.csproj
index 3270084..6fa440e 100644
--- a/modules/mvc/Sanhe.Abp.AspNetCore.Mvc.Wrapper/Sanhe.Abp.AspNetCore.Mvc.Wrapper.csproj
+++ b/modules/mvc/Sanhe.Abp.AspNetCore.Mvc.Wrapper/Sanhe.Abp.AspNetCore.Mvc.Wrapper.csproj
@@ -26,9 +26,4 @@
-
-
-
-
-
diff --git a/modules/mvc/Sanhe.Abp.AspNetCore.Mvc.Wrapper/Sanhe/Abp/AspNetCore/Mvc/Wrapper/AbpAspNetCoreMvcWrapperModule.cs b/modules/mvc/Sanhe.Abp.AspNetCore.Mvc.Wrapper/Sanhe/Abp/AspNetCore/Mvc/Wrapper/AbpAspNetCoreMvcWrapperModule.cs
index ef75f89..cd7c7bf 100644
--- a/modules/mvc/Sanhe.Abp.AspNetCore.Mvc.Wrapper/Sanhe/Abp/AspNetCore/Mvc/Wrapper/AbpAspNetCoreMvcWrapperModule.cs
+++ b/modules/mvc/Sanhe.Abp.AspNetCore.Mvc.Wrapper/Sanhe/Abp/AspNetCore/Mvc/Wrapper/AbpAspNetCoreMvcWrapperModule.cs
@@ -47,11 +47,10 @@ public class AbpAspNetCoreMvcWrapperModule : AbpModule
options.IgnoreReturnTypes.Add();
// api/abp/application-configuration
options.IgnoreReturnTypes.Add();
- // 流
+ // 流内容
options.IgnoreReturnTypes.Add();
// Abp/ServiceProxyScript
options.IgnoreControllers.Add();
-
// 官方模块不包装结果
options.IgnoreNamespaces.Add("Volo.Abp");
diff --git a/modules/mvc/Sanhe.Abp.AspNetCore.Mvc.Wrapper/Sanhe/Abp/AspNetCore/Mvc/Wrapper/ExceptionHandling/AbpExceptionPageWrapResultFilter.cs b/modules/mvc/Sanhe.Abp.AspNetCore.Mvc.Wrapper/Sanhe/Abp/AspNetCore/Mvc/Wrapper/ExceptionHandling/AbpExceptionPageWrapResultFilter.cs
index 672de60..120e803 100644
--- a/modules/mvc/Sanhe.Abp.AspNetCore.Mvc.Wrapper/Sanhe/Abp/AspNetCore/Mvc/Wrapper/ExceptionHandling/AbpExceptionPageWrapResultFilter.cs
+++ b/modules/mvc/Sanhe.Abp.AspNetCore.Mvc.Wrapper/Sanhe/Abp/AspNetCore/Mvc/Wrapper/ExceptionHandling/AbpExceptionPageWrapResultFilter.cs
@@ -17,72 +17,71 @@ using Volo.Abp.ExceptionHandling;
using Volo.Abp.Http;
using Volo.Abp.Json;
-namespace Sanhe.Abp.AspNetCore.Mvc.Wrapper.ExceptionHandling
+namespace Sanhe.Abp.AspNetCore.Mvc.Wrapper.ExceptionHandling;
+
+[Dependency(ReplaceServices = true)]
+[ExposeServices(typeof(AbpExceptionPageFilter))]
+public class AbpExceptionPageWrapResultFilter : AbpExceptionPageFilter, ITransientDependency
{
- [Dependency(ReplaceServices = true)]
- [ExposeServices(typeof(AbpExceptionPageFilter))]
- public class AbpExceptionPageWrapResultFilter : AbpExceptionPageFilter, ITransientDependency
+ protected async override Task HandleAndWrapException(PageHandlerExecutedContext context)
{
- protected async override Task HandleAndWrapException(PageHandlerExecutedContext context)
+ var wrapResultChecker = context.GetRequiredService();
+ if (!wrapResultChecker.WrapOnException(context))
{
- var wrapResultChecker = context.GetRequiredService();
- if (!wrapResultChecker.WrapOnException(context))
- {
- await base.HandleAndWrapException(context);
- return;
- }
-
- var wrapOptions = context.GetRequiredService>().Value;
- var exceptionHandlingOptions = context.GetRequiredService>().Value;
- var exceptionToErrorInfoConverter = context.GetRequiredService();
- var remoteServiceErrorInfo = exceptionToErrorInfoConverter.Convert(context.Exception, options =>
- {
- options.SendExceptionsDetailsToClients = exceptionHandlingOptions.SendExceptionsDetailsToClients;
- options.SendStackTraceToClients = exceptionHandlingOptions.SendStackTraceToClients;
- });
+ await base.HandleAndWrapException(context);
+ return;
+ }
- var logLevel = context.Exception.GetLogLevel();
+ var wrapOptions = context.GetRequiredService>().Value;
+ var exceptionHandlingOptions = context.GetRequiredService>().Value;
+ var exceptionToErrorInfoConverter = context.GetRequiredService();
+ var remoteServiceErrorInfo = exceptionToErrorInfoConverter.Convert(context.Exception, options =>
+ {
+ options.SendExceptionsDetailsToClients = exceptionHandlingOptions.SendExceptionsDetailsToClients;
+ options.SendStackTraceToClients = exceptionHandlingOptions.SendStackTraceToClients;
+ });
- var remoteServiceErrorInfoBuilder = new StringBuilder();
- remoteServiceErrorInfoBuilder.AppendLine($"---------- {nameof(RemoteServiceErrorInfo)} ----------");
- remoteServiceErrorInfoBuilder.AppendLine(context.GetRequiredService().Serialize(remoteServiceErrorInfo, indented: true));
+ var logLevel = context.Exception.GetLogLevel();
- var logger = context.GetService>(NullLogger.Instance);
- logger.LogWithLevel(logLevel, remoteServiceErrorInfoBuilder.ToString());
+ var remoteServiceErrorInfoBuilder = new StringBuilder();
+ remoteServiceErrorInfoBuilder.AppendLine($"---------- {nameof(RemoteServiceErrorInfo)} ----------");
+ remoteServiceErrorInfoBuilder.AppendLine(context.GetRequiredService().Serialize(remoteServiceErrorInfo, indented: true));
- logger.LogException(context.Exception, logLevel);
+ var logger = context.GetService>(NullLogger.Instance);
+ logger.LogWithLevel(logLevel, remoteServiceErrorInfoBuilder.ToString());
- await context.GetRequiredService().NotifyAsync(new ExceptionNotificationContext(context.Exception));
+ logger.LogException(context.Exception, logLevel);
+ await context.GetRequiredService().NotifyAsync(new ExceptionNotificationContext(context.Exception));
- if (context.Exception is AbpAuthorizationException)
- {
- await context.HttpContext.RequestServices.GetRequiredService()
- .HandleAsync(context.Exception.As(), context.HttpContext);
- }
- else
- {
- var statusCodFinder = context.GetRequiredService();
- var exceptionWrapHandler = context.GetRequiredService();
-
- var exceptionWrapContext = new ExceptionWrapContext(
- context.Exception,
- remoteServiceErrorInfo,
- context.HttpContext.RequestServices,
- statusCodFinder.GetStatusCode(context.HttpContext, context.Exception));
-
- exceptionWrapHandler.CreateFor(exceptionWrapContext).Wrap(exceptionWrapContext);
-
- context.Result = new ObjectResult(new WrapResult(
- exceptionWrapContext.ErrorInfo.Code,
- exceptionWrapContext.ErrorInfo.Message,
- exceptionWrapContext.ErrorInfo.Details));
- context.HttpContext.Response.Headers.Add(AbpHttpWrapConsts.AbpWrapResult, "true");
- context.HttpContext.Response.StatusCode = (int)wrapOptions.HttpStatusCode;
- }
+ if (context.Exception is AbpAuthorizationException)
+ {
+ await context.HttpContext.RequestServices.GetRequiredService()
+ .HandleAsync(context.Exception.As(), context.HttpContext);
+ }
+ else
+ {
+ var statusCodFinder = context.GetRequiredService();
+ var exceptionWrapHandler = context.GetRequiredService();
+
+ var exceptionWrapContext = new ExceptionWrapContext(
+ context.Exception,
+ remoteServiceErrorInfo,
+ context.HttpContext.RequestServices,
+ statusCodFinder.GetStatusCode(context.HttpContext, context.Exception));
+
+ exceptionWrapHandler.CreateFor(exceptionWrapContext).Wrap(exceptionWrapContext);
+
+ context.Result = new ObjectResult(new WrapResult(
+ exceptionWrapContext.ErrorInfo.Code,
+ exceptionWrapContext.ErrorInfo.Message,
+ exceptionWrapContext.ErrorInfo.Details));
- context.Exception = null; //Handled!
+ context.HttpContext.Response.Headers.Add(AbpHttpWrapConsts.AbpWrapResult, "true");
+ context.HttpContext.Response.StatusCode = (int)wrapOptions.HttpStatusCode;
}
+
+ context.Exception = null; //Handled!
}
}
diff --git a/modules/mvc/Sanhe.Abp.AspNetCore.Mvc.Wrapper/Sanhe/Abp/AspNetCore/Mvc/Wrapper/ExceptionHandling/AbpExceptionWrapResultFilter.cs b/modules/mvc/Sanhe.Abp.AspNetCore.Mvc.Wrapper/Sanhe/Abp/AspNetCore/Mvc/Wrapper/ExceptionHandling/AbpExceptionWrapResultFilter.cs
index 7a642a3..b057372 100644
--- a/modules/mvc/Sanhe.Abp.AspNetCore.Mvc.Wrapper/Sanhe/Abp/AspNetCore/Mvc/Wrapper/ExceptionHandling/AbpExceptionWrapResultFilter.cs
+++ b/modules/mvc/Sanhe.Abp.AspNetCore.Mvc.Wrapper/Sanhe/Abp/AspNetCore/Mvc/Wrapper/ExceptionHandling/AbpExceptionWrapResultFilter.cs
@@ -17,74 +17,73 @@ using Volo.Abp.ExceptionHandling;
using Volo.Abp.Http;
using Volo.Abp.Json;
-namespace Sanhe.Abp.AspNetCore.Mvc.Wrapper.ExceptionHandling
+namespace Sanhe.Abp.AspNetCore.Mvc.Wrapper.ExceptionHandling;
+
+[Dependency(ReplaceServices = true)]
+[ExposeServices(typeof(AbpExceptionFilter))]
+public class AbpExceptionWrapResultFilter : AbpExceptionFilter, ITransientDependency
{
- [Dependency(ReplaceServices = true)]
- [ExposeServices(typeof(AbpExceptionFilter))]
- public class AbpExceptionWrapResultFilter : AbpExceptionFilter, ITransientDependency
+ protected async override Task HandleAndWrapException(ExceptionContext context)
{
- protected async override Task HandleAndWrapException(ExceptionContext context)
- {
- var wrapResultChecker = context.GetRequiredService();
-
- if (!wrapResultChecker.WrapOnException(context))
- {
- await base.HandleAndWrapException(context);
- return;
- }
+ var wrapResultChecker = context.GetRequiredService();
- //TODO: Trigger an AbpExceptionHandled event or something like that.
- var wrapOptions = context.GetRequiredService>().Value;
- var exceptionHandlingOptions = context.GetRequiredService>().Value;
- var exceptionToErrorInfoConverter = context.GetRequiredService();
- var remoteServiceErrorInfo = exceptionToErrorInfoConverter.Convert(context.Exception, options =>
- {
- options.SendExceptionsDetailsToClients = exceptionHandlingOptions.SendExceptionsDetailsToClients;
- options.SendStackTraceToClients = exceptionHandlingOptions.SendStackTraceToClients;
- });
+ if (!wrapResultChecker.WrapOnException(context))
+ {
+ await base.HandleAndWrapException(context);
+ return;
+ }
- var logLevel = context.Exception.GetLogLevel();
+ //TODO: Trigger an AbpExceptionHandled event or something like that.
+ var wrapOptions = context.GetRequiredService>().Value;
+ var exceptionHandlingOptions = context.GetRequiredService>().Value;
+ var exceptionToErrorInfoConverter = context.GetRequiredService();
+ var remoteServiceErrorInfo = exceptionToErrorInfoConverter.Convert(context.Exception, options =>
+ {
+ options.SendExceptionsDetailsToClients = exceptionHandlingOptions.SendExceptionsDetailsToClients;
+ options.SendStackTraceToClients = exceptionHandlingOptions.SendStackTraceToClients;
+ });
- var remoteServiceErrorInfoBuilder = new StringBuilder();
- remoteServiceErrorInfoBuilder.AppendLine($"---------- {nameof(RemoteServiceErrorInfo)} ----------");
- remoteServiceErrorInfoBuilder.AppendLine(context.GetRequiredService().Serialize(remoteServiceErrorInfo, indented: true));
+ var logLevel = context.Exception.GetLogLevel();
- var logger = context.GetService>(NullLogger.Instance);
+ var remoteServiceErrorInfoBuilder = new StringBuilder();
+ remoteServiceErrorInfoBuilder.AppendLine($"---------- {nameof(RemoteServiceErrorInfo)} ----------");
+ remoteServiceErrorInfoBuilder.AppendLine(context.GetRequiredService().Serialize(remoteServiceErrorInfo, indented: true));
- logger.LogWithLevel(logLevel, remoteServiceErrorInfoBuilder.ToString());
+ var logger = context.GetService>(NullLogger.Instance);
- logger.LogException(context.Exception, logLevel);
+ logger.LogWithLevel(logLevel, remoteServiceErrorInfoBuilder.ToString());
- await context.GetRequiredService().NotifyAsync(new ExceptionNotificationContext(context.Exception));
+ logger.LogException(context.Exception, logLevel);
- if (context.Exception is AbpAuthorizationException)
- {
- await context.GetRequiredService()
- .HandleAsync(context.Exception.As(), context.HttpContext);
- }
- else
- {
- var statusCodFinder = context.GetRequiredService();
- var exceptionWrapHandler = context.GetRequiredService();
-
- var exceptionWrapContext = new ExceptionWrapContext(
- context.Exception,
- remoteServiceErrorInfo,
- context.HttpContext.RequestServices,
- statusCodFinder.GetStatusCode(context.HttpContext, context.Exception));
-
- exceptionWrapHandler.CreateFor(exceptionWrapContext).Wrap(exceptionWrapContext);
-
- context.Result = new ObjectResult(new WrapResult(
- exceptionWrapContext.ErrorInfo.Code,
- exceptionWrapContext.ErrorInfo.Message,
- exceptionWrapContext.ErrorInfo.Details));
+ await context.GetRequiredService().NotifyAsync(new ExceptionNotificationContext(context.Exception));
- context.HttpContext.Response.Headers.Add(AbpHttpWrapConsts.AbpWrapResult, "true");
- context.HttpContext.Response.StatusCode = (int)wrapOptions.HttpStatusCode;
- }
+ if (context.Exception is AbpAuthorizationException)
+ {
+ await context.GetRequiredService()
+ .HandleAsync(context.Exception.As(), context.HttpContext);
+ }
+ else
+ {
+ var statusCodFinder = context.GetRequiredService();
+ var exceptionWrapHandler = context.GetRequiredService();
+
+ var exceptionWrapContext = new ExceptionWrapContext(
+ context.Exception,
+ remoteServiceErrorInfo,
+ context.HttpContext.RequestServices,
+ statusCodFinder.GetStatusCode(context.HttpContext, context.Exception));
+
+ exceptionWrapHandler.CreateFor(exceptionWrapContext).Wrap(exceptionWrapContext);
+
+ context.Result = new ObjectResult(new WrapResult(
+ exceptionWrapContext.ErrorInfo.Code,
+ exceptionWrapContext.ErrorInfo.Message,
+ exceptionWrapContext.ErrorInfo.Details));
- context.Exception = null; //Handled!
+ context.HttpContext.Response.Headers.Add(AbpHttpWrapConsts.AbpWrapResult, "true");
+ context.HttpContext.Response.StatusCode = (int)wrapOptions.HttpStatusCode;
}
+
+ context.Exception = null; //Handled!
}
}
diff --git a/modules/mvc/Sanhe.Abp.AspNetCore.Mvc.Wrapper/Sanhe/Abp/AspNetCore/Mvc/Wrapper/Filters/AbpWrapResultFilter.cs b/modules/mvc/Sanhe.Abp.AspNetCore.Mvc.Wrapper/Sanhe/Abp/AspNetCore/Mvc/Wrapper/Filters/AbpWrapResultFilter.cs
index b3838db..a86a86a 100644
--- a/modules/mvc/Sanhe.Abp.AspNetCore.Mvc.Wrapper/Sanhe/Abp/AspNetCore/Mvc/Wrapper/Filters/AbpWrapResultFilter.cs
+++ b/modules/mvc/Sanhe.Abp.AspNetCore.Mvc.Wrapper/Sanhe/Abp/AspNetCore/Mvc/Wrapper/Filters/AbpWrapResultFilter.cs
@@ -6,36 +6,35 @@ using System.Threading.Tasks;
using Volo.Abp.AspNetCore.Mvc;
using Volo.Abp.DependencyInjection;
-namespace Sanhe.Abp.AspNetCore.Mvc.Wrapper.Filters
+namespace Sanhe.Abp.AspNetCore.Mvc.Wrapper.Filters;
+
+public class AbpWrapResultFilter : IAsyncResultFilter, ITransientDependency
{
- public class AbpWrapResultFilter : IAsyncResultFilter, ITransientDependency
+ public async Task OnResultExecutionAsync(ResultExecutingContext context, ResultExecutionDelegate next)
{
- public async Task OnResultExecutionAsync(ResultExecutingContext context, ResultExecutionDelegate next)
+ if (ShouldWrapResult(context))
{
- if (ShouldWrapResult(context))
- {
- await HandleAndWrapResult(context);
- }
-
- await next();
+ await HandleAndWrapResult(context);
}
- protected virtual bool ShouldWrapResult(ResultExecutingContext context)
- {
- var wrapResultChecker = context.GetRequiredService();
+ await next();
+ }
- return wrapResultChecker.WrapOnExecution(context);
- }
+ protected virtual bool ShouldWrapResult(ResultExecutingContext context)
+ {
+ var wrapResultChecker = context.GetRequiredService();
- protected virtual Task HandleAndWrapResult(ResultExecutingContext context)
- {
- var options = context.GetRequiredService>().Value;
- var actionResultWrapperFactory = context.GetRequiredService();
- actionResultWrapperFactory.CreateFor(context).Wrap(context);
- context.HttpContext.Response.Headers.Add(AbpHttpWrapConsts.AbpWrapResult, "true");
- context.HttpContext.Response.StatusCode = (int)options.HttpStatusCode;
+ return wrapResultChecker.WrapOnExecution(context);
+ }
- return Task.CompletedTask;
- }
+ protected virtual Task HandleAndWrapResult(ResultExecutingContext context)
+ {
+ var options = context.GetRequiredService>().Value;
+ var actionResultWrapperFactory = context.GetRequiredService();
+ actionResultWrapperFactory.CreateFor(context).Wrap(context);
+ context.HttpContext.Response.Headers.Add(AbpHttpWrapConsts.AbpWrapResult, "true");
+ context.HttpContext.Response.StatusCode = (int)options.HttpStatusCode;
+
+ return Task.CompletedTask;
}
}