Deepak Tiwari

Deepak Tiwari

  • NA
  • 27
  • 958

How to prevent whole site to load in iframe except one page

Sep 11 2018 7:02 AM
I've implemented an asp.net MVC site. I want to prevent the whole site to load in the iframe except one page. I added below code under web config.
<httpProtocol>
<customHeaders>
<add name="X-Frame-Options" value="SAMEORIGIN" />
</customHeaders>
</httpProtocol>
This code of web config prevents the whole site to load in the iframe. I try to remove 'X-Frame-Options' option from the view where only I want to allow the iframe
public ActionResult Ads()
{
Response.Headers.Remove("X-Frame-Options");
return View();
}
But when i run this code X-Frame-Options not removed from header. Please suggest me what can I do?