Is there a single place where I can put content on an ASP.NET MVC 4 website that will show up on every page?

StackOverflow https://stackoverflow.com/questions/18964326

문제

I have an MVC 4 site and I want to prevent users from showing my site in an iframe. I know I must add the XFO header X-FRAME-OPTIONS with the value DENY in my responses but I wanted to ask if there is a single place where I can put this so that all my responses send this.

도움이 되었습니까?

해결책

For anyone who needs to do this in the future, this is how I did this

void Application_BeginRequest(object sender, EventArgs e)
{
  Response.Headers["X-FRAME-OPTIONS"] = "DENY";
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top