If Session("Username") IsNot Nothing Then
Label1.Text = "Welcome, " & Session("Username").ToString()
Else
Response.Redirect("~/Default.aspx")
End If
You need to check for if it's not null before you reference it. You were doing the opposite. You were checking to see if it's null, verifying it was, then referencing it. That's why you get a NullReferenceException
. Basically all null reference exceptions are the same, you're trying to perform an operation on an object that is null.