diff --git a/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/Builder/AbpApplicationBuilderExtensions.cs b/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/Builder/AbpApplicationBuilderExtensions.cs index fab4a4bb80..a409355ef0 100644 --- a/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/Builder/AbpApplicationBuilderExtensions.cs +++ b/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/Builder/AbpApplicationBuilderExtensions.cs @@ -84,9 +84,9 @@ namespace Microsoft.AspNetCore.Builder return app.UseMiddleware(); } - public static void UseAbpSecurityHeaders(this IApplicationBuilder app) + public static IApplicationBuilder UseAbpSecurityHeaders(this IApplicationBuilder app) { - app.UseMiddleware(); + return app.UseMiddleware(); } } } diff --git a/framework/src/Volo.Abp.AspNetCore/Volo.Abp.AspNetCore.csproj b/framework/src/Volo.Abp.AspNetCore/Volo.Abp.AspNetCore.csproj index eaa053c91a..b191872339 100644 --- a/framework/src/Volo.Abp.AspNetCore/Volo.Abp.AspNetCore.csproj +++ b/framework/src/Volo.Abp.AspNetCore/Volo.Abp.AspNetCore.csproj @@ -25,7 +25,6 @@ - diff --git a/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/Security/AbpSecurityHeadersMiddleware.cs b/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/Security/AbpSecurityHeadersMiddleware.cs index 09dddfabe7..28b0f3a48e 100644 --- a/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/Security/AbpSecurityHeadersMiddleware.cs +++ b/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/Security/AbpSecurityHeadersMiddleware.cs @@ -1,37 +1,30 @@ +using System.Collections.Generic; using System.Threading.Tasks; using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.Primitives; +using Volo.Abp.DependencyInjection; namespace Volo.Abp.AspNetCore.Security { - public class AbpSecurityHeadersMiddleware + public class AbpSecurityHeadersMiddleware : IMiddleware, ITransientDependency { - private readonly RequestDelegate _next; - - public AbpSecurityHeadersMiddleware(RequestDelegate next) - { - _next = next; - } - - public async Task Invoke(HttpContext httpContext) + public async Task InvokeAsync(HttpContext context, RequestDelegate next) { /*X-Content-Type-Options header tells the browser to not try and “guess” what a mimetype of a resource might be, and to just take what mimetype the server has returned as fact.*/ - AddHeaderIfNotExists(httpContext, "X-Content-Type-Options", "nosniff"); + AddHeaderIfNotExists(context, "X-Content-Type-Options", "nosniff"); /*X-XSS-Protection is a feature of Internet Explorer, Chrome and Safari that stops pages from loading when they detect reflected cross-site scripting (XSS) attacks*/ - AddHeaderIfNotExists(httpContext, "X-XSS-Protection", "1; mode=block"); + AddHeaderIfNotExists(context, "X-XSS-Protection", "1; mode=block"); /*The X-Frame-Options HTTP response header can be used to indicate whether or not a browser should be allowed to render a page in a ,