locked
When to use HttpContext.Current.Session[""] with databinding to Web form ? RRS feed

  • Question

  • User-2071549094 posted

    Hi members,

    I'd like to know when to use

    HttpContext.Current.Session[""] to populate field ?

    Hope someone can give me a step by step tutorial for asp.net webform.

    Tks.

    Friday, December 2, 2016 9:56 AM

All replies

  • User753101303 posted

    Hi,

    I see little reason for doing that. Browser session scoped values are rather for small pieces of data very frequently used (and preferably that could be restored if missing). See this as a kind of small "cache" mechanism for very frequently used values.

    If the question is really about binding a web forms to data stored inside session, I just don't remember to ever have done that (or need that).

    Start maybe the other way round that is to explain first what is the final goal before talking about how to achieve it. You want default values to be the same than those the user previously entered or something like that ?

    Friday, December 2, 2016 10:28 AM
  • User-2071549094 posted

    My goal is like this : I have a form in which user A will fill in the details or rather the details will be auto-filled based on his ID.

    And then this form will have the status changed to Awaiting Authority approval and User A boss - User B will then be able to see the same form when he logged on or when he clicked on the email that is sent to him about this form that requires his attention.

    Hope you can give me some advice. Tks.

    Monday, December 5, 2016 8:34 AM
  • User753101303 posted

    Hummm, it seems you would store that inside a database "as usual"? You don't have a database for now?

    Session is scoped to each browser session and is in memory so it will disappear if the web site stops. The usual way to store data for some time is to use a database.

    Monday, December 5, 2016 8:52 AM
  • User-2071549094 posted

    I have the database and the Store Procedure there already.

    Monday, December 5, 2016 10:00 AM