IE8不保留会话变量 [英] IE8 does not keep Session Variables

查看:182
本文介绍了IE8不保留会话变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我主持一个ASP.NET页面:

If I host an ASP.NET page with:

<%@ Page Language="C#" %>
<!DOCTYPE html>
<script runat="server">

    protected void btn_Click(object sender, EventArgs e)
    {
        lbl.Text = HttpContext.Current.Session["a"] == null ? 
                      "null" : 
                      HttpContext.Current.Session["a"].ToString();
    }
    protected void btn_Click2(object sender, EventArgs e)
    {
        lbl.Text = HttpContext.Current.Cache["a"] == null ? 
                      "null" : 
                      HttpContext.Current.Cache["a"].ToString();
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            HttpContext.Current.Session["a"] = "CBA";
            lbl.Text = "assigned Session Variable";

            HttpContext.Current.Cache.Add(
                    "a", "ABC", null, 
                    DateTime.Now.AddHours(2), TimeSpan.Zero, 
                    CacheItemPriority.NotRemovable, null);
        }
    }

</script>

<html>
<head>
    <title>Testing Session</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Button ID="btn" runat="server" Text="read Session" OnClick="btn_Click" />&nbsp;&nbsp;
        <asp:Button ID="btn2" runat="server" Text="read Cache" OnClick="btn_Click2" />
        <hr />
        <asp:Label ID="lbl" runat="server" />
    </div>
    </form>
</body>
</html>

我得到分配的会话变量 text,但点击后Session对象总是 null

on the first run I do get the assigned Session Variable text, but upon click the Session object is always null

我有一个选项需要转打开/关闭以使用正常的会话变量?

Id there an option I need to turn on/off to use the normal Session Variables ?

在IIS 6.0和Cassini(VS 2008和2010下)中正常工作。

works fine on IIS 6.0 and Cassini (under VS 2008 and 2010).


我开始对所发生的事情没有任何想法:o(

I'm starting to be without ideas on what's going on :o(

非常感谢任何帮助!

上面示例页面的过程

更多测试表明这只发生在IE(在这种情况下是ie8),Firefox,Safari,Opera,Chrome他们都给出了正确的答案

More tests shows that this only happens in IE (ie8 in this case), Firefox, Safari, Opera, Chrome they all give the correct "answer"


检查屏幕演员情况


推荐答案

问题可能是域中的下划线。删除_并查看是否发生了相同的事情

the problem may be the underscores in the domain. remove the _ and see if the same thing happens

这篇关于IE8不保留会话变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆