For example, I want to set "X-Content-Type-Options":"nosniff" to prevent mime sniffing, I could set in web.config,
<add name="X-Content-Type-Options" value="nosniff" />
I also could set the value in global.asax.cs
protected void Application_PreSendRequestHeaders(Object source, EventArgs e) {
HttpContext.Current.Request.Headers.Add("X-Content-Type-Options", "nosniff");
}
What is the difference?
Should I set the header on both places?
Is there any best practice for that?