'Blazor with .NET6 add Response Headers
I'm trying to sort out the OWASP recommendation in my Blazor Web Assembly project.
Usually, in other .NET Core projects I added this code
app.Use((context, next) =>
{
context.Response.GetTypedHeaders().CacheControl =
new Microsoft.Net.Http.Headers.CacheControlHeaderValue()
{
MustRevalidate = true,
NoCache = true,
NoStore = true,
};
context.Response.Headers.Add("X-Content-Type-Options", "nosniff");
context.Response.Headers.Add("Content-Security-Policy",
"default-src 'none'; " + "script-src 'self'; " +
"connect-src 'self'; " +
"img-src 'self'; " +
"style-src 'self'; " +
"base-uri 'self'; " +
"form-action 'self'; " +
"frame-ancestors 'none';");
return next.Invoke();
});
The first problem is app.Use() doesn't exists. Also, if I run the OWASP tool, I have a quite long list of issues.
How can I configure all the OWASP recommendations in my application?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|


