Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. session object to store class objects

session object to store class objects

Scheduled Pinned Locked Moved ASP.NET
tutorialquestion
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    deepalititi
    wrote on last edited by
    #1

    i have address class. i have to store this class object in session object until when application is not closed. how to do it?please provide some guidance

    S T N 3 Replies Last reply
    0
    • D deepalititi

      i have address class. i have to store this class object in session object until when application is not closed. how to do it?please provide some guidance

      S Offline
      S Offline
      sulabh2020
      wrote on last edited by
      #2

      Hi deepali as per i know about session, any thing carry by session remain until the application alive, respective of session time alloted to it.

      Hello Forum Always be in touch to help about the topic ASP.NET

      1 Reply Last reply
      0
      • D deepalititi

        i have address class. i have to store this class object in session object until when application is not closed. how to do it?please provide some guidance

        T Offline
        T Offline
        Talal Sultan
        wrote on last edited by
        #3

        Session is a dictionary where you can add object based on key/value pair. When you want to add something, you give a key that you should use later to retrieve the object. So, supposing that your class is called Address, you would save it in session like this:

        Address myAddress = new Address();
        // do something with myAddress
        Session["address"] = myAddress;

        To retrieve it, you would do this:

        Address mySessionAddress = (Address)Session["address"];

        I put "address" as an example for a key, but you can use any string. Just be sure to use the same string to put in session and retrieve from session. Hope this helps Talal

        "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." --Rich Cook

        1 Reply Last reply
        0
        • D deepalititi

          i have address class. i have to store this class object in session object until when application is not closed. how to do it?please provide some guidance

          N Offline
          N Offline
          N a v a n e e t h
          wrote on last edited by
          #4

          deepalititi wrote:

          i have to store this class object in session object until when application is not closed.

          Application is not closed means ? Do you mean browser ? If yes Talal's solutions is the best. Else you need to go with application variables.


          My Website | Ask smart questions

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups