【问题标题】:ASP.NET Session State - Works In Firefox & IE8, not in ChromeASP.NET 会话状态 - 适用于 Firefox 和 IE8,不适用于 Chrome
【发布时间】:2013-01-24 16:06:26
【问题描述】:

我正在尝试使用会话状态传递四个项目,如下所示:

    protected void createFirstNameSessionVariable(object sender, EventArgs e)
    {
        Session["FirstName"] = firstName.Value;
        Session.Timeout = 60;
        TextBox1.Text = Session["FirstName"].ToString(); 
    }

    protected void createLastNameSessionVariable(object sender, EventArgs e)
    {
        Session["LastName"] = lastName.Value;
        Session.Timeout = 60;
        TextBox2.Text += Session["LastName"].ToString();
    }
    protected void createIdSessionVariable(object sender, EventArgs e)
    {
        Session["FacebookId"] = facebookId.Value;
        Session.Timeout = 60;
        TextBox3.Text += Session["FacebookId"].ToString();
    }
    protected void createEmailSessionVariable(object sender, EventArgs e)
    {
        Session["Email"] = email.Value;
        Session.Timeout = 60;
        TextBox4.Text += Session["Email"].ToString();
    }

在 Firefox 和 IE8 中,我可以使用以下命令将它们放在另一个页面上:

    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["FacebookId"] != null)
        {
            name = Session["FacebookId"].ToString();
            studentButton.Text = name;
        }
        else
        {
            studentButton.Text = "fail";
        }
    }

然而,在 Chrome 中,按钮标签设置为失败,因为会话变量在接收端具有空值。

在 IIS 7.0 管理器上,会话状态当前设置为“处理中” 模式:使用 Cookie 名称:ASP.NET_SessionId 超时:20 分钟

选中使用主机身份进行模拟。

感谢您的帮助。

【问题讨论】:

    标签: asp.net google-chrome session iis internet-explorer-8


    【解决方案1】:

    确保您在 Chrome 中允许使用 cookie。

    【讨论】:

    • - Chrome 中允许使用 Cookie。我还应该提到,这段代码是在 Facebook 应用程序中运行的。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-23
    相关资源
    最近更新 更多