开发者

Iframe 3rd party cookie issue in internet explorer

I am building an ASP.NET 3.5 application in which I have a page which loads another page in a different domain in an iframe. Below is the for Default.aspx page:

<asp:Content ID="Content1" ContentPlaceHolderID="mainContent" runat="server">
    <iframe src="isite.aspx" runat="server" width="100%" height="100%" scrolling="auto">

    </iframe>
</asp:Content>

Below is the iframe page isite.aspx:

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title>Untitled Page</title>
    </head>
    <body style="margin: 0; text-align: center;">
        <form id="Form1" name="frmSubmit" action="https://mysite.com/Login.asp"
        method="POST" runat="server">
        <span style="font-family: Arial">
            <asp:ImageButton ID="ImageButton1" runat="server" PostBackUrl="https://mysite.com/Login.asp" ImageUrl="/ajax-loader.gif" /> Please wait...
    <br />
        </span>
        <input type="hidden" name="txtUserName" size="30" maxlength="50" value="admin"
            onkeypress="Javascript:CheckKeyPress('ID')"/>
        <input type="hidden" name="pwdPassword" size="30" maxlength="25" value="password"
            onkeypress="Javascript:CheckKeyPress('P')"/>
        </form>
    </body>
    </html>

Below is the isite.aspx.cs page:

    protected void Page_Load(object sender, EventArgs e)
    {
        Page.ClientScript.RegisterStartupScript(Page.GetType(), "click", "<script language=javascript>document.getElementById('" + ImageButton1.ClientID + "').click();</script>");
    }

This works fine in Firefox,Safari and Chrome but it dosent work in IE 7 or 8. In IE it gives me a HTTP 500 error page. After doing some research on it I figured that its a cookie issue in IE a开发者_运维知识库nd tried the below soutions:

  1. Added the following code to the Global.asax:

    protected void Application_BeginRequest(object sender, EventArgs e)

    {

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

    }

  2. Added the following line of code to the Page_Init and Page_Load events

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

None of these solutions worked for me. What am I missing?


Adding P3P headers is a best practice if you want a subframe to be able to use cookies, but you should look at the server logs to figure out why a HTTP/500 is getting generated in the first place, since it's the server/framework that's raising the error.

You also might want to turn off friendly errors in IE (see Tools / Internet Options / Advanced)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜