Session.Item ("Hello") vs Session ("Hello")

Are there any advantages to using one over the other other than reading?

+2


source to share


3 answers


No, they do the same. Session ["item"] is the same as Session.Item ["item"].



+11


source


You will be accessing the same collection with.

Its just hangs on classic ASP where the session object is implemented as a COM object. COM can designate one property as the default property (which usually takes an indexing parameter). In the case of Session, the Item property is the default property.



To make it easier for Classic ASP Server to port code to .NET, the Session, Server, Request, Response, and Application classes were created similarly between Classic and .NET ASP.

+5


source


Personally, I find that referencing a property explicitly (Session.Item ("Hello")) is always more readable than relying on the default property (Session ("Item")), but readability at the expense of more typing. If typing is an issue for you, switch to Ruby-on-Rails.

-2


source







All Articles