codice:
<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
If Not Me.IsPostBack Then
Me.Session.Add("x", "y")
End If
Me.Label1.Text = Me.Session.SessionID
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server" Text="" EnableViewState="false"></asp:Label>
<hr />
<asp:LinkButton ID="LinkButton1" runat="server" EnableViewState="false">refresh</asp:LinkButton>
</div>
</form>
</body>
</html>
prova con e senza l'istruzione
Me.Session.Add("x", "y")
Se la sessione non esiste ha quel comportamento. Ma appena la sessione acquista vita, quel comportamento scompare.