page scope variables in ASP.NET
<p>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 ?</p>

<pre><code> 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
</code></pre>

<p>or </p>

<pre><code>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
</code></pre>

<p>And also Is ViewState custom per user? </p>
