Using Session between Pages

1. Create A Session in Default.aspx Page & Redirect to other page


Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        Session("eid") = "009383"
        Session.Timeout = 1  'make session for 1 minute
        Response.Redirect("Default2.aspx")
    End Sub


Access A Session in default2.aspx page.

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        Response.Write(Session("eid") & "v")
        '   Session.Clear()   ''clear the value part of session
    End Sub


2. Use global.asax for Application Settings

Eg. Application(“pagecount”) = 0

Application Variable Can be accessed by all user.
Therefore You need to Lock and unlock Application Variable When using it.

Application.Lock()
        Application("Pagecount") = Integer.Parse(Application("Pagecount").ToString) + 1
        Application.UnLock()


- Vinod Kotiya

Comments

Popular Posts