Wrox Programmer Forums
ASP.NET 1.x and 2.0 Application Design Application design with ASP.NET 1.0, 1.1, and 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.x and 2.0 Application Design section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old April 28th, 2005, 02:43 PM
Registered User
Join Date: Apr 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default HOW-TO Maintain a Class Object in Session

Hello All,

My background is in JSP and am having problem understand ASP.Net.

I am trying to maintain a class instance throughtout a session. I instantiated a class in the code-behind of an aspx. How can I refer to this instance from other aspx pages (i.e. using the same class instance instead of create a new one)?


Old April 28th, 2005, 09:21 PM
planoie's Avatar
Friend of Wrox
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts

Put the class instance in the session collection, then retrieve it when you need to use it.

Session("myClassInstance") = myClass
myClass = CType(Session("myClassInstance"), MyClassType)

Session["myClassInstance"] = myClass;
myClass = (MyClassType)Session["myClassInstance"];


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to maintain session between Domain &subdomain im.imrankhan PHP How-To 1 September 5th, 2008 12:44 PM
Maintain the session in asp.net samgaya1983 ASP.NET 2.0 Professional 2 June 29th, 2007 03:37 AM
Database Session Class sw8370 Pro PHP 0 February 4th, 2006 12:19 PM
Accessing Session variables from custom class mohyneenm ASP.NET 1.0 and 1.1 Professional 2 January 26th, 2005 07:25 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.