【问题标题】:Internet Explorer Iframe cookie issueInternet Explorer iframe cookie 问题
【发布时间】:2011-01-02 00:08:28
【问题描述】:

我正在构建一个 ASP.NET 3.5 应用程序,其中我有一个页面,该页面在 iframe 的不同域中加载另一个页面。下面是 Default.aspx 页面:

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

    </iframe>
</asp:Content>

下面是iframe页面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>

下面是 isite.aspx.cs 页面:

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

这在 Firefox、Safari 和 Chrome 中运行良好,但在 IE 7 或 8 中运行良好。在 IE 中它给了我一个 HTTP 500 错误页面。在对其进行了一些研究后,我认为这是 IE 中的 cookie 问题,并尝试了以下解决方案:

  1. 将以下代码添加到 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. 将以下代码行添加到 Page_Init 和 Page_Load 事件中

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

这些解决方案都不适合我。我错过了什么?

【问题讨论】:

  • 我也有同样的问题,希望能找到解决办法,我刚刚找到了这个旧帖子connect.microsoft.com/IE/feedback/details/369240/…,上面说这是IE8中的一个错误,IE团队会解决,什么时候?!我不知道:(
  • 您找到解决方案了吗?

标签: asp.net internet-explorer iframe cookies


【解决方案1】:

“p3p”应该像“P3P”这样大写

【讨论】:

    【解决方案2】:

    我在 IE 中遇到了同样的问题,并且没有任何在线解决方案可以帮助我,在我的情况下,我强迫用户在 iframe 中再次登录,这对我有用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-09-11
      • 1970-01-01
      • 2012-12-12
      • 2011-06-23
      • 2010-12-22
      相关资源
      最近更新 更多