2
Reply

What Is The Difference Between ViewState and SessionState?

Rohatash Kumar

Rohatash Kumar

13y
13.7k
1
Reply

    Session state is the feature of ASP.NET based web applications using which values of a variable may be persisted and then posted to another page.

    Viewstate property of a page or a control, or a viewstate object for a variable value, may also be created to persist its value across a postback. However, the viewstate value are for page level, i.e. they cannot be posted across to another page.

    Session State is useful for storing values that must be persisted across
    multiple pages by the same user. ViewState is useful for storing
    serializable data that must be persisisted across PostBacks by a single
    page. If you use Session State, the value you insert will remain in memory
    until (1) The Session times out, or (2) Your code removes it. If you use
    ViewState, the value you insert will remain in ViewState until the user
    requests a different page.

    ViewState stores data betwen PostBacks by putting it into a hidden form
    field on the client HTML doc. when the doc is Posted Back, the values are
    read from the hidden form field and stored in memory until the page has
    finished processing. If ViewState is particularly large (and I'm talking KBs
    here, not 6 bytes), it can negatively affect the speed at which the HTML doc
    is downloaded by the browser.


    http://kalitinterviewquestions.blogspot.com/

    Hi Dear,

    View state is the client side state mangement technique,while

    session state is server side state manegement technique.

    View state can be maintained within the page and

    session state can be maintained accross the page.

    View state stored on page its self while

    session state can be stored on Inproc,OutProc,SqlServer.

     

    Happy Programming:

    Deep gautam