Webbrowser control looses sessionid on "newwindow"

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am creating a new instance of the webbrowser control in vb, and using that
to browse to a website. HOwever, this website will open up a popup that
contrains info and this window (when opened) has the "Server Error" page.

From what I understand, this is an issue of the web browser not functioning
as it should (i.e. persisting the session id & the cookie). Where it is
breaking is the webbrowser control calling a New Window (IE Windows) and it
doesn't seem to be smart enough to pass these along.

To demostrate this, use this website: http://www.yvesrepiquet.com/idtest.php
1) open it with an instance of IE
2) (close all ie windows), build a new VB (or vb.net) project and add the
webbrowser control. Navigate to that page and click the link.

-I am using an instance of the MS Webbrowser control (shdocvw.dll - version
6.0.2900.2919)
-My Internet Explorer is version: 6.0.2900.2180 (latest)
-Windows XP SP2 (fully patched)

Now what I have tried is the following:
- adding the site to my "Trusted" zone
- adding the site to my "local" zone
- tested VB6 webbrowser control
- tested VB.Net 2005 webbrowser control (points to the same dll)
- navigate & navigate2 methods


Does anyone have a work around or fix to this issue yet? I do not have
control over the server side of the server so I am looking for a client based
solution.

Thanks,

Ryan
 
Hi Ryan,

I haven't gone to the trouble of creating a beresque browser to test your
problem, so I am only guessing...

1. Try a button instead of a hyperlink with a javascript href value.
Normally the href is fired before the click event. To disable the href
firing use href="#" for href="javascript:void();"

2. also in your windowopen function specify the target frame as "_blank" to
force the creation of a new window (but I think in the case of an embedded
webbrowser control this will open a new instance of Internet Explorer on the
clients machine.) A possible workaround if this is the case is to use
window.createpopup or window.showModalDialog or to use a floating <div> or
even a message box (alert('line one /nline two');)

I trust this is the solution you are looking for.


Regards.
 
Rob,

I do not have control over the web page. However, after talking with them
they are passing the target frame "_blank". However, the window isn't
initiated by a link, it's in a function that is validating data (i.e if there
are errors then they are output to the window).

To me this seems like a browser/control bug. The webbrowser control is
really just an instance of shdocvw, so why can't it keep it's session id when
a new window is instantiated. If I use just a IE window (instead of an
instance of the webbrowser control), then it all works fine. However, I need
to use the webbrowser control to keep the browser encapsulated inside my
application.

Any ideas would be greatly appreciated.

Ryan
 
Hi Ryan,

My concern with the link is that the href property is firing before the
onclick event so that in effect href passes a call to the shdocvw control to
begin navigation and that the following onclick event which uses javascript
with window.open calls to an Internet Explorer Process. The new Internet
Explorer Process creates a new session ID..

I just did a test with your test page in my own shdocvw browser. In the
webbrowser1_NewWindow2 event which is fired when the hyperlink element is
clicked the activeelement href is "javascript:;" - your href value .
If the new_window event is cancelled, no window is opened. However allowing
the window creation creates a new instance of "Internet Explorer" with the
new session ID.... as I expected.

The problem is that the shwdocvw control has one connection. Navigating away
from the control with a new window creates a new connection.

Although I have not tested it I think the solution is to target the
hyperlink to the current session instance with target=_self..... so your
hyperlink should look something like this <a
href=http://myweb.com/Nextpage.php target="_self"></a>

Forget the javascript to create a new window. Keep your navigation within
the shdocvw control flat (with no new window calls) and use back and forward
methods for navigation.

I am pretty sure this is the solution as there have been other posts about
beresque browsers creating new Internet Explorer processes with new window
calls.

Have a look at the MSDN help interface.. They only use ModalDialogs for
popups. Navigation does not create window.open events.

Regards.
 
Back
Top