Solved

Can I use Session object by adding asp.dll to references?

Posted on 2002-04-09
7
263 Views
Last Modified: 2010-05-02
Hi..

I have some code from a guys here for training. I see the code that they have declared a Session object in VB! and have implemented a shoppng cart. they say they have some prob but i am not aware of the prob.

My query is can the Session object be created and used in VB?

thanx & regards,
rajiv
0
Comment
Question by:rajivraj123
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 18

Expert Comment

by:mdougan
ID: 6928635
Under .Net I think that there is a Session class, so, it's possibly .Net code.  But under VB6, no.  The code that you are seeing is probably ASP code, which is written in VB Script.  Looks very much like VB, but if it references a Session or Response objects then it is ASP.  
0
 
LVL 18

Expert Comment

by:mdougan
ID: 6928641
One other thought, there are objects in VB, such as MAPI objects that do have a Session object (I think that it's actually defined as a MAPISession though....)
0
 
LVL 5

Expert Comment

by:rkot2000
ID: 6928708
you can't create a session object in vb(session is created by iis), but you can use it. you need to add references to your vb project.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 5

Accepted Solution

by:
rkot2000 earned 50 total points
ID: 6928728
This is extremely useful if you would like to have direct access to the ASP intrinsic objects; for example, Application, Session, Response, Request, and Server.

http://support.microsoft.com/default.aspx?scid=kb;en-us;Q238274

HOWTO: Access Session and Application Variables from Within a Visual Basic Component (Q230149)

http://support.microsoft.com/default.aspx?scid=kb;EN-US;q230149&GSSNB=1
0
 

Author Comment

by:rajivraj123
ID: 6930397
Thanx! :)

I have a class in VB with say 2 public variables. I create a object of this class, set the values of the variables and put in the session, as mentioned in those articles. Now, when I get the session variable in a ASP page, how can I type-cast the object from the session to the class I created in VB?
0
 
LVL 5

Expert Comment

by:rkot2000
ID: 6931127


it's very bad idea to store an object with session:
full story :
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnasdj00/html/asp1100.asp

Sessions and object references don't mix

If you plan on storing COM objects in the session object, you need to understand the performance implications. Most of the components created using Visual Basic 6.0 and even Visual C++ are single-threaded apartment (STA) components. The rules of COM dictate that the calls to an STA component ultimately need to execute on the same thread where the component was created.

Now, IIS maintains a pool of threads to service user requests. When an incoming request arrives, IIS picks the next free thread to process the request. Unfortunately, when you store an STA component in the session object, you have locked the session to a specific thread. Any further requests from that user session need to get routed to the original thread to satisfy the aforementioned rule. If the original thread is already busy processing another request, the new request will need to wait.

As an analogy, pretend on your first trip to the grocery store you went to aisle three for checking out. Now on every subsequent return to the grocery store you must always use aisle three, even when aisle three is crammed with shoppers and other aisles are open and available. Clearly, this can create problems.

p.s with asp you have late binding so you have something like this
dim x

set x=session("My_object")


0
 

Author Comment

by:rajivraj123
ID: 6932905
Agreed, but if I am implemeting a shopping cart, where wil I store the user-specific data? Isnt session the only way out?`
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Access query that references subform 5 49
How to measure sizes and angles in scanned images ? 3 99
VB6 - Scroll Mouse wheel on Picturebox 13 118
VB6 Enviroment 3 32
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question