473,770 Members | 4,355 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

session.remove vs session.content s.remove

Is there a reason to use session.remove over session.content s.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 7197
"tshad" <ts**********@f tsolutions.comw rote in message
news:e1******** ******@TK2MSFTN GP06.phx.gbl...
Is there a reason to use session.remove over session.content s.remove?
Session.Remove isn't even listed in MSDN - Session.Content s.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.Content s.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**@markNOSPA Mrae.comwrote in message news:e%******** ********@TK2MSF TNGP04.phx.gbl. ..
"tshad" <ts**********@f tsolutions.comw rote in message
news:e1******** ******@TK2MSFTN GP06.phx.gbl...
>Is there a reason to use session.remove over session.content s.remove?

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

Aug 5 '06 #3
"Juan T. Llibre" <no***********@ nowhere.comwrot e in message
news:e0******** ******@TK2MSFTN GP04.phx.gbl...
re:
>Session.Remo ve isn't even listed in MSDN

Yes, it is :

http://msdn2.microsoft.com/en-us/lib...te.remove.aspx
That's HttpSessionStat e.Remove, not Session.Remove. ..
You use Session.Content s.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 HttpSessionStat e.Remove, not Session.Remove. ..
Read again, Mark :

HttpSessionStat e.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 HttpSessionStat e 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.whateve r, you are really using a shortcut to HttpContext.Ses sion,
which provides access to the HttpSessionStat e 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("Sessio nVariable1")
to get or set the value of the session state variable SessionVariable 1.

But, in reality, Session("Sessio nVariable1") and
HttpContext.Cur rent.Session("S essionVariable1 ").
are both one and the same thing : ways to access the HttpSessionStat e class.

re:
>You use Session.Content s.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.Conten ts.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**@markNOSPA Mrae.comwrote in message news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..
"Juan T. Llibre" <no***********@ nowhere.comwrot e in message
news:e0******** ******@TK2MSFTN GP04.phx.gbl...
>re:
>>Session.Remov e isn't even listed in MSDN

Yes, it is :

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

That's HttpSessionStat e.Remove, not Session.Remove. ..
>You use Session.Content s.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.comwrot e in message
news:e$******** ******@TK2MSFTN GP03.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**@markNOSPA Mrae.comwrote in message
news:O2******** ******@TK2MSFTN GP02.phx.gbl...
"Juan T. Llibre" <no***********@ nowhere.comwrot e in message
news:e$******** ******@TK2MSFTN GP03.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
3470
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) Case "Authenticated" Case "CI_CODE" Case "organisation_description" Case "location_description"
1
3110
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 ) = "" Session.Contents.Remove( item ) end if next 'item
1
2784
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 process of transitioning the server on which it runs from Microsoft Windows 2000 Server, to 2003 server (going from IIS 5 to IIS 6). This problem hasn't really occurred on the 2000 server machine, but it's happening MUCH more on the new 2003 box (not...
1
1626
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 only eliminate every other or every third entry. If I refresh the page about 0 times everything eventually clears out. Anyone know why it would do this? I don't want to use Session.Abandon because there are a few Session.Contents I want to...
5
22155
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 Global.asax file. One of the variables I set up is:
4
1330
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 parts of it using session variables and got no where. The (Pseudo) code that doesn't work at all is as follows: Page_Load( ) { if ( !IsPostBack )
12
2210
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 thing because it forces IIS to affiliate the Session with the Thread on which the STA object is created. This means all subsequent requests for that session can only be handled by that worker thread and can therefore result it in poor...
11
3725
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 all the session names but when I include the session.contents it gives me the following error:
2
2023
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 more, very odd... Any ideas? :S im clueless For each key In Session.Contents()
0
9602
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9439
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10237
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10071
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9882
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7431
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6690
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5467
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2832
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.