ASP Session with VB 6 problem

Posted on 2004-11-15
Last Modified: 2012-06-22
On a WinNT 4 platform (using Visual Basic 6 and ADO) we had used

    Session("VW") = r!VW_NF

Now we are using Windows 2000.
That code, shown above, now raises "No default property for object."  
If I paste the statement into the debug window though, it runs without error.
If I modify it to be

    Session("VW") = CStr(r!VW_NF)

it runs properly.

OK.  So I found a work-around.  
But now, I have a worse problem.

We have a class that is just a set of properties (let’s call it clsXXX):

Public Value1 As String
Public Value2 As String
 . . .
Public Val__n As String

In (for example) ThePage_Respond(), we have

    Dim ob As clsXXX
    Set ob = New clsXXX

    GetValues ob    ' This fills the properties.  This Sub is not part of the class, it only fills in the object’s properties

    Set Session("XXX") = ob    '  <——<<<
    Set Session("XXX") = Nothing

At the line marked by the arrow, nothing happens.
The Watch window shows that Session("XXX") is still Variant/Empty.

I need to be able to store objects in the Session.

Is there some flaw in the Windows 2000 environment that cripples Internet Information Server’s ASP objects (Server, Application, Request, Response & Session)?
Are there other issues I am going to run into?

Question by:BrianWren
    LVL 5

    Expert Comment

    Have you tried using the code behind to handle these values rather than trying to stuff them all in a session variable?
    LVL 9

    Expert Comment


    Do not place an object in session.

    Here some links ....(applicable to also)


    LVL 5

    Expert Comment

    What you CAN do is change the object to a string and change your function that filles it to create a delimited string.  They you will need a function to parse out and read it.

    Much better to use separate variables for what you need.

    Or use code behind
    LVL 9

    Author Comment

    In a VB IIS application, your HTML contains replaceable tags.  In your VB project, you specify the signature of these tags.  Default is WC@, but the books recommend changing that.  We use WC.

    So when the VB encounters <WC_ while processing an html template, it calls the [templateName]_ProcessTag(ByVal TagName As String, TagContents As String, SendTags As Boolean) Sub, filling in the TagName argument with all that is between the < and >, and filling in the TagContents with all that is between the <WC_...> and </WC_...> tags.

    With <WC_Name>-default-</WC_Name> the function would be called with TagName = "WC_Name" and TagContents = "-default".

    When processing a request for a template, first the [templateName]_Respond() sub is called, and when that sub has [templateName].WriteTemplate, the [templateName]_ProcessTag() Sub is called once for each replaceable tag.  Whatever the value of TagContents is when the sub ends, that value will replace the whole tag in the resultant web page.

    I have some cases where I fill in 80 or 90 separate values on the page, all of which come from an Oracle DB.  
    I don't want to open that record 80 or 90 times.
    I tried using a UDT but that cannot be done because it requires late binding, and an IIS project with even one instance of late binding won't compile.

    We switched to using classes, because that facilitates early binding.  (You can cause late binding of classes or early binding.  There is no way to use early binding with User-Defined Types in VB/IIS.)

    In the Respond routine we get the values then close the recordset, and in the ProcessTag routine we use the exposed parts of the class to fill in the values on the page:

    Private Sub [templatename]_ProcessTag( ..., ... )

        Dim ob As clsWhatever
        Set ob = Session("Whatever I Stored The Object As")

        Select Case Lcase$(TagName)
            Case "wc_name":         TagContents = ob.Name
            Case "wc_addr":         TagContents = ob.Addr
            Case "wc_ ...":
        End Select

        Set ob = Nothing

    End Sub

    Doing this with individual variables in the Session would be a big mess.
    This ran on our WinNT, IIS 4, VB 6 (SP 5) network, but does not on our Win2K

    Additionally, no one has addressed the issue that

        Session("VW") = r!VW_NF

    ran before, but requires

        Session("VW") = CLngr!VW_NF)

    now.  This isn’t an issue of storing objects in the Session, but it still fails to fly.

    Part of the reason we had to innovate this is that, whereas this could easily have been done in an .EXE with a global object, that won't fly in IIS.  Global object belong to everyone making a request, and this needed to have user-by-user resolution.

    riyasjef, those links were informative.  They were largely focused on storing objects to re-use between requests, and we aren't doing that in this code I'm focusing on.  (I do do that in one place, and that might turn out to be disastrous later, but the topics of those links seem to be slightly to the side of this particular problem, especially considering that I have difficulty assigning a recordset field’s value to a simple Session item.

    LVL 9

    Author Comment

    I believe the answer to this can be found in

    It has to do with security, and the situation when debugging VB in the IDE.

    The ASP session is under the user IWAM_<machine-name>, but the IDE is under the account of the developer.  Since the COM+ objects are instantiated by one of these ‘users,’ the ‘user’ associated with the IDE cannot gain access to the objects belonging to IWAM_<machine-name>, and vice verse.


    Accepted Solution

    PAQed with points refunded (500)

    Community Support Moderator

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Course: HTML5 for Beginning Beginners

    Are you looking for an efficient introduction to HTML5? Have you tried other HTML5 courses and found them too complex? Do you need just the basics of HTML5 to use with Wordpress or other content management system? If you said yes to any of these questions, this course is for you.

    When pages do not download correctly, and you don't know why, the first thing you do is to look at the HTML source code of that page, but not all the downloaded files appear always clearly. If your source includes a javascript that computes the name…
    I've been asked to discuss some of the UX activities that I'm using with my team. Here I will share some details about how we approach UX projects.
    Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
    This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

    779 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

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now