ASP.Net State Management

State Management
1.       Hidden Tags
2.       Request variable
3.       Cookies
4.       URL Rewriting  default.aspx?session= Session.SessionID
5.       Session Tracking : match  Session.SessionID

    Cookies: If enabled in browser then work Eg:

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim ck As New HttpCookie("myCookie", "vinod")
            Dim d As New Date
            ck.Expires = d 'persist for 1 day
        End Sub

    In cookies2.aspx access it like this:

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            If Not Request.Cookies.Item("myCookie") Is Nothing Then
            End If

        End Sub

    Request: Request.Form, Request.querystring, Request.Params

    For Request.forms remove runat=server and add action="default4.aspx" in Form Tag

    If Request.HttpMethod.Equals("Get") Then
                Dim v = Request.QueryString("mode")
                Dim v = Request.Form("t"'where t is the input name = "t" id ="t" in html
    End If

     Tracing: Its a debugging mechanism. To enable trace Add following line in your web.config file inside system.web replace ( and ) with < and >

    (trace enabled="true " pageOutput="false" requestLimit ="10" traceMode="SortByTime "/)

    pageOutput="True" if wanna show trace at client else use http:\url\trace.axd   on server to get trace detail. It also show server variables detail in bottom.

    Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click

            Trace.Write("Trace Method")
                Dim i, j, k
                i = 10
                k = 0
                j = i / k
            Catch ex As Exception
            End Try
        End Sub

    -Vinod Kotiya


    Most Viewed Post

    solution for facebook waiting

    Connect Sony XPLOD MEX-BT2500 Bluetooth CD Receiver with ur mobile

    Crystal Report : Show data horizontally (Left to right) i.e. columns as rows

    Google+ Followers