Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Session State (Session.Abandon()) 1

Status
Not open for further replies.

kizmar2

Programmer
Joined
May 25, 2004
Messages
164
Location
US
Getting (another) error and not sure why or how to fix it:

Error
Code:
Exception Details: System.Web.HttpException: Session state is not available in this context.

Line 38:         Session.Abandon()

PubClasses.vb
Code:
Imports System.Web
Imports System.Web.SessionState
Imports System.Data.SqlClient

Public Class PubClasses
    Inherits System.Web.HttpApplication

    Public Function LogOut()
        ' Remove session values
        Session.Abandon()

        ' Pass user back to login page
        Server.Transfer("index.aspx")
    End Function
End Class

KizMar
------------
 
Whoohffff...

Evidently I need to get a better handle on what the difference is between coding on a public *.vb class file, and the aspx.vb files.

Are the public variables in the *.vb file the same memory space for each session (span across all sessions)? Or are they still session specific?

KizMar
------------
 
Check the help on variable scope to better understand.

Jim
 
The key to using the Session is by looking at what class it is from (HttpContext.Current). As you use it at page level, that context is available (i.e. there is a page there to serve to) whereas when you create you own class it isn't (much like how you couldn't use Response.Redirect).


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top