locked
How to save and load the state of a webpage? RRS feed

  • Question

  • User-295753397 posted

    Hello!

    I am displaying a webpage, I want to save the state of the entire webpage, so that when the user logs in next time, I could load that state, and he will be back to where he left off.

    Can anyone help me accomplish this? How can I save and load this type of state?

    Thanks! 

    Friday, September 14, 2007 6:36 PM

All replies

  • User599138732 posted

    There is no solution for this that fits all scenarios. And that is because the "state of a page" or the way a page is rendered may depend on many aspects:

    1. View State

    2. Session State

    3. Query String Values

    4. AJAX - if you have AJAX in your page then things may have changed in the client that the server is not aware of.

    5. Data in a database.

    6. Data posted from another page.

    7. Any other source of information (files for example) that acts during the rendering of the page.

    So, there is no straight-forward-standard way of saving the state of a page. You simply need to make sure that you know what information affects the way your page renders, save those values somewhere and then load them (and process them) if you want to bring your page to the same "state".. One common method is to store the values in the query string so that the user can bookmark the page. The values in the session state are lost when the user closes the browser so those you would need to store in a database or somewhere else if you want to restore them. The ViewState is lost when you go to another page, etc....

    If you still want to try obscure methods, there is articles out there that explain how to save the viewstate to a persistent medium. Look at this: http://www.codeproject.com/useritems/SaveViewState.asp

    Happy development!

    David

    Friday, September 14, 2007 8:23 PM
  • User1564875471 posted

     so that when the user logs in next time, I could load that state, and he will be back to where he left off.

    what is the things in the pgae you want to restore ?

    if you want to remember the user custom themes and styles you may use the profile to save and restore these user specific data .

    and if you want to save the transactions the user did ,you can save these transaction in the database and restore it when the user back again .

     

    Regards,

     

    Sunday, September 16, 2007 5:38 AM
  • User-960726523 posted

    It's non simple but if you use MVC is a bit simple.

    1. Have a [Serializable] Context (the Model) in which you have all object of the page. Every object must be serializable

    2. Save (serialize) the context on file/db or where you want.

    3. Load the context the next time

    Regards

    Filippo

    Friday, May 27, 2016 12:57 PM