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 Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
HttpContext.Current.Session["a"] = "A";
lbl.Text = "assigned Session Variable";
}
}
</script>
<html>
<head>
<title>Testing Sessions</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="btn" runat="server" Text="reload" OnClick="btn_Click" />
<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
More tests shows that this only happens in IE (ie8 in this case), Firefox, Safari, Opera, Chrome they all give the correct "answer"
check the screen cast of the situation
You must change your url par_2008_64 in par200864 because in explorer the underscore doesn't work and the session becomes null
Traditional session state requires cookies to be enabled for the site in question. Is it at all possible you have Internet Explorer set to block the cookie coming from the server, and the other browsers not set that way? That would explain the difference in behavior. You should be able to use Fiddler (cf. http://www.fiddler2.com/fiddler2/) to watch the HTTP traffic between IE and the server, and see if IE is sending the cookie back to the server. I strongly suspect the answer is "no".
You can potentially set cookieless sessions (e. g. http://msdn.microsoft.com/en-us/library/ms972429.aspx) in your web.config file to confirm this as well; if cookieless works, then there ya go.
If anyone find this "bug", do a simple thing to resolve it.
Had the same issue at a customer. Removing and adding the application won't solve the issue in this case. The trick is: Replace or remove the underscore in the url!