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