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 @@ - - - - -