Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8
This is the forum to discuss the Wrox book Beginning ASP.NET 2.0 by Chris Hart, John Kauffman, David Sussman, Chris Ullman; ISBN: 9780764588501
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 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 August 31st, 2006, 10:58 AM
Friend of Wrox
 
Join Date: Jul 2006
Posts: 238
Thanks: 0
Thanked 2 Times in 2 Posts
Send a message via MSN to rsearing
Default

THANK YOU THANK YOU THANK YOU!!

 
Old August 31st, 2006, 02:43 PM
Registered User
 
Join Date: Aug 2006
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Rob, session variables are pretty much as you said...they are global variables available to every page in that browser session...when the session is finished, the variables go away. I find session variables easy to use in ASP.NET. To define a variable, it's

Session.Add("VariableName", "Value")

To refer to it on another page, it's:

Session.Item("VariableName")

Since they are not strongly typed, and are in fact stored as objects, you may have to convert them to a variable type before using them.

 
Old August 31st, 2006, 09:23 PM
Friend of Wrox
 
Join Date: Jul 2006
Posts: 238
Thanks: 0
Thanked 2 Times in 2 Posts
Send a message via MSN to rsearing
Default

Terry--THANKS!! Just the info I was looking for.

Is there a central file that you declare them in--or if you reference them in one page---(other than default.aspx) all others will see them?

Is there a link to a fairly easy-to-follow explanation of these?

It's funny--I hate to get on my soapbox...but I graduated with a BA of IT..and felt that I was cheated. I learned a little bit about a lot and the extent of my programming was command-line stuff to learn C++--NOTHING real-world. I have bought three Wrox books and a Dreamweaver book--and I'm teaching myself. I remember I was project managing a development team to design a web app for Cerner---but I didn't get in the trenches..and remembered them talking about having to give up on having functionality to "back" up several pages--because it would degrade performance with having to transfer all these "session" variables. I assume that this "session" is something that is stored somewhere..that contains all these variables..for a certain period of time?? Is the "session", I assume, transferred with each time you go to a web page?

Terry--Thank you so much for your help!!!

Kind Regards,
Rob

 
Old September 1st, 2006, 12:00 PM
Registered User
 
Join Date: Aug 2006
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I usually just assign session variables as I need them...I don't really know if that's best practice or not. They aren't stored anywhere but in the web server's memory...you could write them to a database for long-term storage if you want. For session variables that always have an initial value that you want all users to initialize with, you can create them in the global.asax file. There are some great beginner videos at http://msdn.microsoft.com/vstudio/ex...ult.aspx#video. They are for Visual Web Developer, but they mostly apply to VS as well. There is one on state management that will get you started pretty well.

My understanding is that ASP.NET 2.0 handles them more efficiently than previous versions, but I suppose that if you have enough of them and lots of visitors to the site, you could run into memory problems. Still, I believe it's what most people use. Using profiles is an alternative to session variables in some cases, because it writes the values to a database, are strongly typed, and handles all the database stuff automatically. There are varying opinions on when you should use profiles and when you should use session variables, but I think the consensus is to use profiles for user-specific info, such as name, address, etc. that you want to keep, and use session variables for temporary storage of data that you want available for each page. The fact is, either can be used for either. The web server only keeps session variables in memory for as long as the session lasts. So if you are on a site and you close the browser, or even leave the page sitting until the timeout has expired (default is 30 min. I think), the web server releases those variables automatically.

Hang in there...I'm still new at this stuff too...I'm working on a project for a client that presents in some ways to me a "trial by fire", but I learn best that way anyway.

Terry


 
Old September 1st, 2006, 01:10 PM
Friend of Wrox
 
Join Date: Jul 2006
Posts: 238
Thanks: 0
Thanked 2 Times in 2 Posts
Send a message via MSN to rsearing
Default

Thank you very much Terry!






Similar Threads
Thread Thread Starter Forum Replies Last Post
Interface between web app and win app alienaheart ASP.NET 2.0 Professional 4 August 4th, 2009 09:29 AM
ASP.NET App Scroll Issue aspcoder BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 3 November 14th, 2008 07:50 PM
02 IN 01 Desktop App (App+Wind Handler) pk_ocp .NET Framework 2.0 0 February 26th, 2008 02:58 PM
Convert a VB.Net app to a web app? furjaw VB.NET 3 September 24th, 2007 12:27 PM
WroxShoppingCart problem terryh0416 BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 4 August 31st, 2006 08:24 AM





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