473,473 Members | 1,534 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

session.remove vs session.contents.remove

Is there a reason to use session.remove over session.contents.remove?

Don't they both remove the key and data from the contents collection?

I assume that session(x) = nothing does essentially the same thing but is
actually deleted later by the GC.

Thanks,

Tom
Aug 4 '06 #1
6 7155
"tshad" <ts**********@ftsolutions.comwrote in message
news:e1**************@TK2MSFTNGP06.phx.gbl...
Is there a reason to use session.remove over session.contents.remove?
Session.Remove isn't even listed in MSDN - Session.Contents.Remove is...
http://msdn.microsoft.com/library/de...710538d6c1.asp
Aug 5 '06 #2
re:
Session.Remove isn't even listed in MSDN
Yes, it is :

http://msdn2.microsoft.com/en-us/lib...te.remove.aspx

You use Session.Contents.Remove in ASP and Session.Remove in ASP.NET.

Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"Mark Rae" <ma**@markNOSPAMrae.comwrote in message news:e%****************@TK2MSFTNGP04.phx.gbl...
"tshad" <ts**********@ftsolutions.comwrote in message
news:e1**************@TK2MSFTNGP06.phx.gbl...
>Is there a reason to use session.remove over session.contents.remove?

Session.Remove isn't even listed in MSDN - Session.Contents.Remove is...
http://msdn.microsoft.com/library/de...710538d6c1.asp

Aug 5 '06 #3
"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:e0**************@TK2MSFTNGP04.phx.gbl...
re:
>Session.Remove isn't even listed in MSDN

Yes, it is :

http://msdn2.microsoft.com/en-us/lib...te.remove.aspx
That's HttpSessionState.Remove, not Session.Remove...
You use Session.Contents.Remove in ASP and Session.Remove in ASP.NET.
Seems like you can use either in ASP.NET 2...
Aug 6 '06 #4
re:
>http://msdn2.microsoft.com/en-us/lib...te.remove.aspx

That's HttpSessionState.Remove, not Session.Remove...
Read again, Mark :

HttpSessionState.Remove Method
Deletes an item from the session-state collection.

....which is exactly what Session.Remove does.

The long explanation :

Access to session values and functionality is available using the HttpSessionState class,
which is accessible through the Session property of the current HttpContext,
or the Session property of the Page.

Read through this link :
http://msdn2.microsoft.com/en-us/lib...t.session.aspx

When you use Session.whatever, you are really using a shortcut to HttpContext.Session,
which provides access to the HttpSessionState class.

Because ASP.NET pages contain a default reference to the System.Web namespace
(which contains the HttpContext class), you can reference the members of HttpContext
on an .aspx page without the fully qualified class reference to HttpContext.

For example, you can use just Session("SessionVariable1")
to get or set the value of the session state variable SessionVariable1.

But, in reality, Session("SessionVariable1") and
HttpContext.Current.Session("SessionVariable1").
are both one and the same thing : ways to access the HttpSessionState class.

re:
>You use Session.Contents.Remove in ASP and Session.Remove in ASP.NET.
Seems like you can use either in ASP.NET 2...
You can, although I don't see the purpose of writing extra, unneeded code (why use
"Session.Contents.Remove" when "Session.Remove" will do the exact same thing ?)
....but try using Session.Remove in ASP.

You'll get this nasty spitback at you :
Microsoft VBScript runtime error '800a01b6'
Object doesn't support this property or method: 'Remove'

:-)

Bottom line : Session is not an ASP nor an ASP.NET object.

Session is an IIS object to which both ASP and ASP.NET
provide access to, using different methods and properties.

Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"Mark Rae" <ma**@markNOSPAMrae.comwrote in message news:%2****************@TK2MSFTNGP04.phx.gbl...
"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:e0**************@TK2MSFTNGP04.phx.gbl...
>re:
>>Session.Remove isn't even listed in MSDN

Yes, it is :

http://msdn2.microsoft.com/en-us/lib...te.remove.aspx

That's HttpSessionState.Remove, not Session.Remove...
>You use Session.Contents.Remove in ASP and Session.Remove in ASP.NET.
Seems like you can use either in ASP.NET 2...

Aug 6 '06 #5
"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:e$**************@TK2MSFTNGP03.phx.gbl...
Bottom line : Session is not an ASP nor an ASP.NET object.

Session is an IIS object to which both ASP and ASP.NET
provide access to, using different methods and properties.
Thanks for the explanation.
Aug 6 '06 #6

"Mark Rae" <ma**@markNOSPAMrae.comwrote in message
news:O2**************@TK2MSFTNGP02.phx.gbl...
"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:e$**************@TK2MSFTNGP03.phx.gbl...
>Bottom line : Session is not an ASP nor an ASP.NET object.

Session is an IIS object to which both ASP and ASP.NET
provide access to, using different methods and properties.

Thanks for the explanation.
Me too.

It actually answered some explanation on having to use fully qualified names
when using VS and not having to if you build your pages in DW (which I
normally do). So when I would go to the couple of actual dlls that I have
built by hand using DW and then compiling from the command line, I find that
I need to use the FQN which I always need to look up since I normally don't
have to use them and always forget which ones to use.

Thanks,

Tom
Aug 8 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Colin Steadman | last post by:
I have created a function to kill all session variables that aren't in a safe list. This is the function - Sub PurgeSessionVariables For Each Item In Session.Contents Select Case Trim(Item)...
1
by: YT | last post by:
Howdy, Why the heck wouldn't this work: for each item in Session.Contents if NOT( Instr( item, "customer_" ) = 1 OR Instr( item, "user_" ) = 1 ) Then Session.Contents( item ) = ""...
1
by: Scott Lyon | last post by:
I'm maintaining (read: I didn't write it, nor do I have the time to spend to rewrite it) an application that is suddenly giving me grief. The reason I say suddenly, is because we're in the...
1
by: Dan King | last post by:
At a summary page, I am trying to clean up Session.Contents so the user can go back to the main page and not retain any unnecessary info. I have entered this into my summary page, but it seems to...
5
by: tshad | last post by:
When I log of I do: HttpContext.Current.Session.Clear() FormsAuthentication.SignOut() The problem is that it clears the variables that I set up in my Session_Start function in my...
4
by: Paul Rogers | last post by:
I have an existing .NET ( 1.1) application, and I ran Microsoft's FxCop on it, and it screamed at me about directly using textbox.text values instead of session values. So, I tried to re-write...
12
by: Anthony Jones | last post by:
Here's a question that I've not been able to get a definitive answer to. Creating an STA object (such as a typical VB6 object) and assigning to the ASP Session store is a bad thing. It's a bad...
11
by: Jerry | last post by:
I'm using this code: Dim strName For Each strName in Session.Contents Response.Write strName & " - " & Session.Contents(strName) & "<BR>" Next If I only do a response.write strName, it shows...
2
by: Lasse Edsvik | last post by:
Hello I have a problem with running classic asp on a windows 2003 server. For some reason it doesnt remove the sessions. I reload page and it removes some, reload again and it removes a few...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.