Question Base Class Property resets on Postback

Ahmad.Hassan

New member
Joined
Jun 25, 2020
Messages
1
Programming Experience
1-3
I have a base class in asp.net application.
Base class has a property and i am setting the value of property in derived class.
On Page post back property resets. How can i retain it.
 

Skydiver

Staff member
Joined
Apr 6, 2019
Messages
1,406
Location
Virginia Beach, VA
Programming Experience
10+
Recall every web request causes a new object to be instantiated. If you want something to be transmitted to the next object, you need to put the data into a hidden control (e.g. the WebForms technique), put the data into a cookie, or put the data into the session state or cache. The default for the session state and cache is in-proc only, so they won't survive the app pool shutting down (or crashing), and obviously won't be sent to other web front ends in a load balanced web farm. To get that kind of effect, you would need to switch to IIS's other modes for session state: database or session state server.
 
Top Bottom