0

I have this problem when trying to read a session in another asp.net page.

Object reference not set to an instance of an object.

If Session("cne").Equals("") Then
Response.Redirect("Default.aspx")
End If

I'm setting the session in the Default page with this code :

Session("cne") = cne.Text

Thanks.

2
  • It would be useful if you could post some additional code. Based on what you have here there is no reason for the error, but since it is happening that would suggest either the default page is not getting called first, or there is other code somewhere setting the value to null. More context will help determine what is going on. Commented Jun 19, 2010 at 23:56
  • @ckramer: the error is obvious, actually. Commented Jun 20, 2010 at 1:21

1 Answer 1

2
Dim cne = Session("cne")
If cne Is Nothing OrElse cne.Equals("") Then 
    Response.Redirect("~")
End If
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.