我用TWebBrowser控件做了一个程序。打开一个网站,这个网站是要登录的。当我点击网站中的链接时(链接是打开一个新窗口浏览),发现新的IE窗口竟然要我重新登录了,也就是说Session在新窗口里面失效了?用IE打开这个网站,点击这个链接是不会要求重新登录的,大家帮忙啊。看看怎么回事儿。我不希望这个地方重新登录,能和IE一样就行大家帮忙啊,高分求助。这个问题有解么?

解决方案 »

  1.   

    When you click a hyperlink in an application that is hosting the WebBrowser control, a new page opens in Internet Explorer. In this scenario, the session cookie is lost, and you may have to log on again. This behavior occurs because Internet Explorer is a different process than the application process. A session cookie cannot be shared between processes. To maintain the session state in this scenario, you can use the NewWindow2 event to open the new page in another form in the application. This event is triggered by the WebBrowser control. 
    For more information, visit
    http://support.microsoft.com/kb/184876
      

  2.   

    you can use the NewWindow2 event to open the new page in another form in the application
      

  3.   

    MVP兄弟,你知道Microsoft的KB怎么能看英文原文的么?
    翻译出来的文档太难读了。
      

  4.   

    Session一般是通过会话Cookie实现的,IE的会话Cookie不能跨进程,用IE打开弹窗没有另起进程,而你的程序TWebBrowser弹窗后起了IE进程(与你的程序不是同一进程),所以失效。要解决,象jiangsheng(蒋晟.Net[MVP]) 说的,捕获 TWebBrowser 的弹窗事件,to open the new page in another form in the application.....注意“another form in the application”