I need to access some variables in a page in web application. The scope of variables is just in that specific page. which one is the solution ? Session or ViewState ? or any better solution ?
Private Property UserId() As Integer
Get
If Not ViewState("UserId") Is Nothing Then
Return CType(ViewState("UserId"), Integer)
Else
Return -1
End If
End Get
Set(ByVal Value As Integer)
ViewState("UserId") = Value
End Set
End Property
or
Private Property UserId() As Integer
Get
If Not Session("UserId") Is Nothing Then
Return CType(Session("UserId"), Integer)
Else
Return -1
End If
End Get
Set(ByVal Value As Integer)
Session("UserId") = Value
End Set
End Property
And also Is ViewState custom per user?