Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

BUG: VB5 ActiveX Document loses Session context. HELP!

0 views
Skip to first unread message

Chris Page

unread,
Oct 24, 1997, 3:00:00 AM10/24/97
to

Microsoft Knowledgebase article Q168431
(http://premium.microsoft.com/support/kb/articles/q168/4/31.asp) addresses
Internet Explorer failing to load an ActiveX document created with VB5.
The article indicates that the sample HTML generated by the VB Setup Wizard
to load the ActiveX document in IE is not correct. The Setup Wizard
generates the following:

<HTML>
<OBJECT ID="SampleDoc1"
CLASSID="CLSID:11111111-1111-1111-1111-111111111111"
CODEBASE="Project1.CAB#version=1,0,0,0">
</OBJECT>

<SCRIPT LANGUAGE="VBScript">
Sub Window_OnLoad
Document.Open
Document.Write "<FRAMESET>"
Document.Write "<FRAME SRC=""SampleDoc1.VBD"">"
Document.Write "</FRAMESET>"
Document.Close
End Sub
</SCRIPT>
</HTML>

And the Knowledgebase article recommends changing that to:

<HTML>
<OBJECT ID="SampleDoc1"
CLASSID="CLSID:11111111-1111-1111-1111-111111111111"
CODEBASE="Project1.CAB#version=1,0,0,0">
</OBJECT>

<SCRIPT LANGUAGE="VBScript">
Sub Window_OnLoad
Location.Href = "SampleDoc1.VBD"
End Sub
</SCRIPT>
</HTML>

"The changes to the Window_OnLoad procedure allow the VBD file to be
launched successfully, thus the ActiveX Document will initialize and
display within Microsoft Internet Explorer."

Here's the problem with their recommended fix. We use the AsyncRead method
from within our ActiveX documents to communicate with the web server.
Specifically, we call an ASP that returns the values of many session-level
variables set in ASP before calling the ActiveX document. When we call
this ASP from within the ActiveX document loaded by using the first method
above, all of the session variables are returned. However, when we load an
ActiveX document using the method that the Knowledgebase article recommends
(to fix ANOTHER problem), all of the session variables are blank (i.e. it
appears that the ActiveX documents are being loaded in a different session
context than the HTM file that is loading it).

What follows is a code sample to reproduce this problem. If you have any
thoughts as to a work-around, or if a fix is in the works (*hint*
Microsoft), please let me know.

Thanks,
Chris Page
William M. Mercer, Inc.
Louisville, KY USA
chris...@mercer.com


PROJECT1.ASP
==================================
<%@ LANGUAGE="VBSCRIPT" %>
<% Response.Expires = 0 %>
<% Session("TestVariable") = "TestValue" %>

<HTML>
<OBJECT ID="SampleDoc1"
CLASSID="CLSID:11111111-1111-1111-1111-111111111111"
CODEBASE="Project1.CAB#version=1,0,0,0">
</OBJECT>

<SCRIPT LANGUAGE="VBScript">
Sub Window_OnLoad
MsgBox "<%= Session("TestVariable") %>" ' it's there...
Location.Href = "SampleDoc1.VBD"
End Sub
</SCRIPT>
</HTML>


SampleDoc1.VBD
==================================
Private Sub UserDocument_Show()
AsyncRead "http://<webserver>/SessionData.asp", vbAsyncTypeFile,
"SessionData"
End Sub

Private Sub UserDocument_AsyncReadComplete(AsyncProp As AsyncProperty)
Dim SessionString
' Read Session data sent from web server
Open AsyncProp.Value For Input As #1 ' Open file for input.
If Not EOF(1) Then
Input #1, SessionString
' The following MsgBox displays "SessionString = TestValue" if we call
the ActiveX document
' using the method generated by the setup wizard, but displays
"SessionString = " if we
' use the method recommended by the Knowledgebase article...
MsgBox "SessionString = " & SessionString
End If
Close #1


SessionData.ASP
==================================
<%@ LANGUAGE="VBSCRIPT" %>
<% Response.Expires = 0 %>
<% Response.Write Session("TestVariable") %>


0 new messages