Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IE8 does not keep Session Variables

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>

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 ?

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

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

Any help is greatly appreciated!


the process of the example page above

alt text

alt text


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

alt text


check the screen cast of the situation

like image 245
balexandre Avatar asked Nov 06 '22 09:11

balexandre


1 Answers

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

like image 86
Rodolfo Avatar answered Nov 14 '22 19:11

Rodolfo