I have created a public property on my ASP.Net which holds a session of an entity. The purpose of which is that the entity is added to as the user fills in a number of steps on a form and then the whole lot is then saved to the database. However, when I go to use the session I am getting the error "object reference not set to an instance of an object".
Here is my code:
Public ReadOnly BreadQuestionnaire as Bread
Implements IQuestionnaire.BreadQuestionnaire
Get
If Me.Session("BreadQuestionnaire") Is Nothing Then
Me.Session("BreadQuestionnaire") = New Bread()
End If
Return TryCast(Me.Session("BreadQuestionnaire"),Bread)
End Get
End Property
It is based upon code that I used in C# which has never given me any trouble before, but I have had VB.Net thrusted on me.
So, can anyone help me?