Last post Dec 16, 2016 06:19 AM by Zhi Lv - MSFT
Dec 15, 2016 10:58 AM|jagan12013|LINK
I'm saving the list object into session like this In action method
HttpContext.Session["AdditionalShippingAddress"] = resultobj;
Another post action while accessing getting null
List<AdditionalShippingAddressModel> shippingAddressList = (List<AdditionalShippingAddressModel>)HttpContext.Session["AdditionalShippingAddress"];
I don't know why it is happening.
Please suggest me.
Thanks In Advance.
Dec 15, 2016 12:10 PM|mgebhard|LINK
Did you make sure the data is not null to begin with?
Other than that, you're describing the danger of using InProc Session without checking for null.
Keep in mind, storing items in Session is the same as storing data in two different places; Session and the Database. The database is typically and should be the system of record. Therefore, if Session is null for any reason you should reload Session from
the system of record - the database. This is a common pattern when using session or any form of secondary persistence.
Dec 16, 2016 06:19 AM|Zhi Lv - MSFT|LINK
First, as mgebhard said, please set a break point and check whether the resultobj is null or not.
Second, perhaps the session expired, please make sure it not exceeded the expiry
Finally, you could check the Session-State Modes, if you are using
InProc mode, the data might loss. You could try to use
SQLServer mode. More details, please refer to this article: