Click to See Complete Forum and Search --> : new to VB.NET, please help


mfancher
April 3rd, 2004, 05:48 PM
What causes Session state variable to not be saved?

I have the following code:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Not IsPostBack Then
'Create a new FlashCard object
FlashCard = New FlashCardClass
'store the object in a Session variable.
Session("FlashCard") = FlashCard
Else
'Get the Session FlashCard object
FlashCard = Session("FlashCard")
End If
RefreshDisplay()
End Sub

The first time through, it runs through If Not IsPostBack and I see the Session("FlashCard") is set.

When I enter text into a text box on the Web Form it displays, which returns me to this code, it runs through the Else, and does not have a value in the
Session("FlashCard")

Aslo, the Session.IsNewSession is = TRUE.

So when I try to use the FlashCard later, it give me the following error:

Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:


Line 55: End Sub
Line 56: Private Sub RefreshDisplay()
Line 57: lblFirst.Text = FlashCard.FirstNumber
Line 58: lblSecond.Text = FlashCard.Operation & FlashCard.SecondNumber
Line 59: End Sub

Does anyone have any idea what's going on here? Any help would be greatly appreciated!

Thanks,

Melena

Craig Gemmill
April 3rd, 2004, 06:18 PM
http://www.jaedworks.com/shoebox/no-cookie/no-cookie-logo.gif
Sounds like a cookie issue. If you are blocking the cookies, then you have to pass the Session ID through the address.
Example: http://www.something.com/hi.aspx?s=10241249214

kasracer
April 3rd, 2004, 06:23 PM
Originally posted by Craig Gemmill
http://www.jaedworks.com/shoebox/no-cookie/no-cookie-logo.gif
Hahaha that's awesome!

mfancher
April 3rd, 2004, 07:14 PM
Thank you!!! My ZoneAlarm was blocking the cookie... Not blocking the cookie makes it work correctly.

Melena