locked
session state data RRS feed

  • Question

  • User-1549531783 posted

    what kind of data could be stored in session state? this was one of the question asked by interviewer. Could you help me, what the interviewer what trying to get out from me.

    Sunday, September 11, 2011 11:59 AM

Answers

  • User-389597101 posted

    In the session state you can store any kind of data but data should be in serialized form. For example if you want any class to store in the session state then it should have Serialized attribute above the class. Hope it helps.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, September 13, 2011 5:57 AM

All replies

  • User-843484705 posted

    Your nanswer is :

    Any amount of data can be stored there because the session is kept on the server side.

    The only limitation is sessionId length, which shouldn't exceed ~4000 bytes - this limitation is implied by HTTP header length limitation to 4Kb since sessionId may be stored in the cookie or encoded in URL (using "URL rewriting") and the cookie specification says the size of cookie as well as HTTP request (e.g. <tt>GET /document.html\n</tt>) cannot be longer then 4kb.

    Sunday, September 11, 2011 12:04 PM
  • User-389597101 posted

    In the session state you can store any kind of data but data should be in serialized form. For example if you want any class to store in the session state then it should have Serialized attribute above the class. Hope it helps.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, September 13, 2011 5:57 AM
  • User825619085 posted

    Hi Venki,

    There is three kind of session state available in asp.net, and you can store any size of object in session but when you need the data from session need casting.

    If you are using inporc mode of session than no need to serialize the object.

    If you are using outproc or sqlserver than you have to serialize the object.

    Tuesday, September 13, 2011 7:30 AM