Enable Iframe in Asp.net application

Asked

Viewed 249 times

1

I have an Asp.net application and I need to put it inside an Iframe.

Turns out it gives Chrome console error:

Refused to display 'domain' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'.

In Mozilla it does not give error, and also shows nothing.

Webconfig is already like this:

 <httpProtocol>
  <customHeaders>
   <add name="Access-Control-Allow-Origin" value="*" />
  </customHeaders>
 </httpProtocol>

I don’t know what to do.

1 answer

0

In his Global.asax.cs, define the following:

protected void Application_PreSendRequestHeaders()
{
    Response.Headers.Remove("X-Frame-Options");
    Response.AddHeader("X-Frame-Options", "AllowAll");
}

ASP.NET MVC applications are not configured by default to appear in iframes.

  • Can I do this on IIS somehow? I’m avoiding republishing the app

  • In theory it has, but it doesn’t work right. This is the best alternative.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.