gpt4 book ai didi

iis-7 - IE8 不保留 session 变量

转载 作者:行者123 更新时间:2023-12-04 21:25:41 28 4
gpt4 key购买 nike

如果我托管一个 ASP.NET 页面:

<%@ 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>

在第一次运行时,我确实得到了 assigned Session Variable文本,但单击 session 对象始终是 null
我需要打开/关闭使用普通 session 变量的选项吗?

在 IIS 6.0 和 Cassini 上运行良好(在 VS 2008 和 2010 下)。

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



任何帮助是极大的赞赏!

上面例子页面的流程

alt text

alt text

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

alt text

check the screen cast of the situation

最佳答案

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

关于iis-7 - IE8 不保留 session 变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3658513/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com