ASP.NET(vb.net) Session.Abandon() - Session Object - Session.Abandon() : The Abandon method destroys all the objects stored in a Session object and releases their resources. If you do not call the Abandon method explicitly, the server destroys these objects when the session times out.
ShotDev Focus:
- ASP.NET(vb.net) Session.Abandon() - Session Object
Example
AspNetSessionAbandon1.aspx
<%@ Page Language="VB" %> <script runat="server"> Sub Page_Load(sender As Object, e As EventArgs) '*** Create Session ***' Session.TimeOut = 20 Session("Name") = "Mr.Weerachai Nukitram" Session("NickName") = "Mr.Win" Session.Add("SiteName","www.ShotDev.Com") '*** Delete Session ***' Session.Abandon() '*** Read Session ***' Dim items As Object For Each items In Session.Keys Me.lblText1.Text = Me.lblText1.Text & items & " = " &Session(items) & "<br>" Next Me.hplLink.Text = "View Session" Me.hplLink.NavigateUrl = "AspNetSessionAbandon2.aspx" End Sub </script> <html> <head> <title>ShotDev.Com Tutorial</title> </head> <body> <form runat="server"> <asp:Label id="lblText1" runat="server"></asp:Label><br /><br /> <asp:HyperLink id="hplLink" runat="server"></asp:HyperLink><br /> </form> </body> </html>
AspNetSessionAbandon2.aspx
<%@ Page Language="VB" %> <script runat="server"> Sub Page_Load(sender As Object, e As EventArgs) '*** Delete Session ***' Session.Abandon() '*** Read Session ***' Dim items As Object For Each items In Session.Keys Me.lblText1.Text = Me.lblText1.Text & items & " = " &Session(items) & "<br>" Next Me.hplLink.Text = "Back" Me.hplLink.NavigateUrl = "AspNetSessionAbandon1.aspx" End Sub </script> <html> <head> <title>ShotDev.Com Tutorial</title> </head> <body> <form runat="server"> <asp:Label id="lblText1" runat="server"></asp:Label><br /><br /> <asp:HyperLink id="hplLink" runat="server"></asp:HyperLink><br /> </form> </body> </html>
Screenshot