Persisting Custom Business Objects
-
I have a number of custom business objects that have private variables, properties and methods coded into class files and compiled into a dll. When I create an instance of one of these objects on a page(.aspx) I can use the properties to modify the attributes of the object. If I then make a postback to the page by clicking a button the object re-initializes itself during Page_Load() and the data is lost. When I use objects in windows forms applications once they are created they persist no matter what events occur within the windows form until you destroy the object. I want to be able to keep the object live so I can use it on this page or any other page I may navigate to. I have used Session to store the objects and this seems to work but it involves checking for an instance of the object in Session on Page_Load() event and I understand that it is not the correct way to do this. All in all, how can I keep an object live on the webserver that can be initialized / created on any page within the web application without using Session. I would appreciate any help with this matter Thank You
-
I have a number of custom business objects that have private variables, properties and methods coded into class files and compiled into a dll. When I create an instance of one of these objects on a page(.aspx) I can use the properties to modify the attributes of the object. If I then make a postback to the page by clicking a button the object re-initializes itself during Page_Load() and the data is lost. When I use objects in windows forms applications once they are created they persist no matter what events occur within the windows form until you destroy the object. I want to be able to keep the object live so I can use it on this page or any other page I may navigate to. I have used Session to store the objects and this seems to work but it involves checking for an instance of the object in Session on Page_Load() event and I understand that it is not the correct way to do this. All in all, how can I keep an object live on the webserver that can be initialized / created on any page within the web application without using Session. I would appreciate any help with this matter Thank You
LeeOvEngland wrote: I want to be able to keep the object live so I can use it on this page or any other page I may navigate to. I have used Session to store the objects and this seems to work but it involves checking for an instance of the object in Session on Page_Load() event and I understand that it is not the correct way to do this. Why not? unless they are bloody enormous this is a perfectly resonable thing to do. Create a wrapper class for your session state to encapsulate the Session["easytomistypename"] stuff and code away. Ryan