1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| public class WebApiApplication : HttpApplication
{
protected void Application_Start()
{
GlobalConfiguration.Configure(WebApiConfig.Register);
}
protected void Application_BeginRequest()
{
if (HttpContext.Current.Request.Url.AbsolutePath.Equals("/", StringComparison.Ordinal))
{
HttpContext.Current.Response.Redirect("/api/default", true);
}
HttpContext.Current.Response.AddHeader("Cache-Control", "no-store");
HttpContext.Current.Response.AddHeader("Content-Security-Policy", "default-src 'self'; frame-ancestors 'none'");
HttpContext.Current.Response.AddHeader("Permissions-Policy", "camera=(), microphone=(), geolocation=(), payment=()");
HttpContext.Current.Response.AddHeader("Pragma", "no-cache");
HttpContext.Current.Response.AddHeader("Referrer-Policy", "no-referrer");
HttpContext.Current.Response.AddHeader("Strict-Transport-Security", "max-age=31536000; includeSubDomains");
HttpContext.Current.Response.AddHeader("X-Content-Type-Options", "nosniff");
HttpContext.Current.Response.AddHeader("X-DNS-Prefetch-Control", "off");
HttpContext.Current.Response.AddHeader("X-Download-Options", "noopen");
HttpContext.Current.Response.AddHeader("X-Frame-Options", "SAMEORIGIN");
HttpContext.Current.Response.AddHeader("X-Permitted-Cross-Domain-Policies", "none");
HttpContext.Current.Response.AddHeader("X-XSS-Protection", "1; mode=block");
}
} |
Partager