Passing object between pages.

Passing object between pages.

Old forum URL: forums.lhotka.net/forums/t/1117.aspx


dcb posted on Monday, September 04, 2006

I have been doing winform applications for a long time now and need to now create a web application.  I am going to use CSLA object but need to get some advice on how to pass objects between pages.  A code example would be greate.

Thanks,

David

 

Henrik replied on Tuesday, September 05, 2006

David

The best way is to store the object in session state between the pages.

Solution 1:
Page1:
Session("object") = YourObject

Page 2:
Dim obj As YourObjectType = DirectCast(Session("object"), YourObjectType)

This is the most performant solution, although it doesn't scale as good as solution 2l.

Solution 2:
If you are reluctant to use session state, one alternative is to store the object in the database on page 1, and send the id of the object, via the querystring, to page 2 and reload it there. This is the most scalable solution but doesn't perform so well.

Hope this helps

/Henrik

dcb replied on Tuesday, September 05, 2006

That helps a lot and makes since.  Thanks for the example.  I will give it a try later today.

Thanks,

David

 

Copyright (c) Marimer LLC