• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 380
  • Last Modified:

ASP Session with VB 6 problem

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?

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

Do not place an object in session.

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





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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

BrianWrenAuthor Commented:
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.

BrianWrenAuthor Commented:
I believe the answer to this can be found in http://support.microsoft.com/?id=259725

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.

PAQed with points refunded (500)

Community Support Moderator

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now