Page cannot be displayed error with IE and Iframe, third party cookie related

Page cannot be displayed error with IE and Iframe, third party cookie related

Recently I came across an issue with IE and a web application that was being displayed within an iframe on another parent page.

When I would load the parent page, I would get a “page cannot be displayed error”.

To make a long story short, my web application needed to set a cookie, and because it was being hosted within an Iframe, this was considered third party. In order to allow IE to set this type of cookie, you need to have a Compact Policy header defined for your page.

To do this in ASP.NET, you can programatically add the header in your code behind like so (forgive the formatting, it was difficult to get this to wrap properly):

 HttpContext.
                Current.
                Response.
                AddHeader("p3p",
                "CP="IDC DSP COR ADM DEVi TAIi " +
                "PSA PSD IVAi IVDi CONi HIS OUR IND CNT"");

Once this is done, your page should be able to set the cookie, and the page should show up just fine (assuming you have the default IE security settings)

Many thanks to Adam Young for pointing me in the right direction on this. 

By | 2018-04-01T02:14:58+00:00 March 27th, 2011|Categories: ASP.NET|Tags: , , , |0 Comments

About the Author:

Leave A Comment