baseline: 小军 WMS 二开代码原始快照(含 SynOABusiness.cs Debugger.Break)
This commit is contained in:
commit
c2b0e7be0d
6522 files changed
+3530643
No files matched your search
+34
@@ -0,0 +1,34 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Opsoft.NetCore.O3App.WebApi
|
||||
{
|
||||
public class CustomResponseHeaderMiddleware
|
||||
{
|
||||
private readonly RequestDelegate _next;
|
||||
|
||||
public CustomResponseHeaderMiddleware(RequestDelegate next)
|
||||
{
|
||||
_next = next;
|
||||
}
|
||||
|
||||
public async Task Invoke(HttpContext context)
|
||||
{
|
||||
//To add Headers AFTER everything you need to do this
|
||||
context.Response.OnStarting(state =>
|
||||
{
|
||||
var httpContext = (HttpContext)state;
|
||||
httpContext.Response.Headers.Add("Strict-Transport-Security", "max-age=31536000");
|
||||
httpContext.Response.Headers.Add("X-Content-Type-Options", "nosniff");
|
||||
httpContext.Response.Headers.Add("X-Xss-Protection", "1");
|
||||
httpContext.Response.Headers.Add("X-Frame-Options", "SAMEORIGIN");
|
||||
httpContext.Response.Headers.Add("Content-Security-Policy", "default-src 'self'");
|
||||
|
||||
//... and so on
|
||||
return Task.CompletedTask;
|
||||
}, context);
|
||||
|
||||
await _next(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user