DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/)
-   ASP.NET (http://www.daniweb.com/forums/forum18.html)
-   -   Session.Add vs. Context.Items.Add (http://www.daniweb.com/forums/thread117899.html)

ericstenson Apr 7th, 2008 11:45 am
Session.Add vs. Context.Items.Add
 
Is there a difference in handling between Session.Add("SOMETHING","somevalue") and Context.Items.Add("SOMETHING","somevalue")?

munr Apr 7th, 2008 3:54 pm
Re: Session.Add vs. Context.Items.Add
 
Quote:

Originally Posted by ericstenson (Post 579308)
Is there a difference in handling between Session.Add("SOMETHING","somevalue") and Context.Items.Add("SOMETHING","somevalue")?



Using Session.Add, the item will be added to the session and available throughout the duration of the session, across all pages.

With Context.Items.Add, the item will be added to the current page request only and accessible up until the page finishes loading, after which the value will be lost. In my experience, this is usually used in conjunction with Server.Transfer to pass values between pages.

Hope this helps.

Mun


All times are GMT -4. The time now is 5:55 am.

Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC