InternetExplorer.Application对象和cookie的容器 [英] InternetExplorer.Application object and cookie container

查看:1013
本文介绍了InternetExplorer.Application对象和cookie的容器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经写在VB.NET以下控制台应用程序:

 的Sub Main()
    昏暗的IE作为对象= CREATEOBJECT(InternetExplorer.Application)
    ie.Visible = TRUE
    ie.Navigate2(HTTP://本地主机:4631 / Default.aspx的)
结束小组

此程序使用 InternetExplorer.Application 自动化对象推出一个IE窗口,并浏览特定的URL。我遇到的问题是,即使我启动我的应用程序的多个实例,与此方法创建的所有IE窗口共享同一个cookie的容器。是否有任何参数,我可以用指定不同的Cookie容器为每个窗口中创建?

这是网页我用来测试的cookie:

 <%@页面语言=C#AutoEventWireup =真正的%GT;
!< D​​OCTYPE HTML PUBLIC - // W3C // DTD XHTML 1.0过渡// ENhttp://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"><脚本=服务器>
    保护无效的Page_Load(对象发件人,EventArgs的发送)
    {
        //商店的东西到会话中,以创建的cookie
        会话[富]栏;
        的Response.Write(Session.SessionID);
    }
< / SCRIPT>
< HTML的xmlns =htt​​p://www.w3.org/1999/xhtml>
<身体GT;
    <表ID =form1的=服务器>< /表及GT;
< /身体GT;
< / HTML>


解决方案

对于的的CreateObject(InternetExplorer.Application)创建一个IE实例和所有你计划的情况下,通过此进程进行通信。 饼干将成为每个进程持有

您可以尝试在你的应用程序 web浏览器控件使用,而不是(见的 http://msdn.microsoft.com/en-us/library/3s8ys666.aspx )。你会发现在 http://msdn.microsoft.com/en -us /库/ aa752044(VS.85)的.aspx 它比较了两种方式的信息。如果你会在你的应用中使用 web浏览器控制应用程序的所有实例都将有他自己的一套饼干,但是只有一组每个进程独立于<$数量饼干C $ C> web浏览器在应用程序的控制。

中的任何过程,你可以随时清除该cookie就以下调用的

  InternetSetOption(IntPtr.Zero,INTERNET_OPTION_END_BROWSER_SESSION,IntPtr.Zero,0);

(见 http://support.microsoft.com/kb/195192/en),这表明更多的时间饼干控股性质。

I have the following console application written in VB.NET:

Sub Main()
    Dim ie As Object = CreateObject("InternetExplorer.Application")
    ie.Visible = True
    ie.Navigate2("http://localhost:4631/Default.aspx")
End Sub

This program uses the InternetExplorer.Application automation object to launch an IE window and navigate a given url. The problem that I encountered is that even if I launch multiple instances of my application, the IE windows that are created with this method all share the same cookie container. Is there any parameter I could use specifying that a different cookie container is created for every window?

This is the web page I used to test cookies:

<%@ Page Language="C#" AutoEventWireup="true" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
    protected void Page_Load(object sender, EventArgs e)
    {
        // Store something into the session in order to create the cookie
        Session["foo"] "bar";
        Response.Write(Session.SessionID);
    }
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<body>
    <form id="form1" runat="server"></form>
</body>
</html>

解决方案

With respect of CreateObject("InternetExplorer.Application") you create an instance of Internet Explorer and all instances of you program communicate through this one process. Cookies will be hold per process.

You can try to use in your application WebBrowser control instead (see http://msdn.microsoft.com/en-us/library/3s8ys666.aspx). You find in http://msdn.microsoft.com/en-us/library/aa752044(VS.85).aspx information which compare two ways. If you will use WebBrowser control in you application all instances of your application will have his own set of cookies, but only one set of cookies per process independent on the number of WebBrowser controls in your application.

Inside of any process you can any time clear the cookie with respect of following call

InternetSetOption(IntPtr.Zero, INTERNET_OPTION_END_BROWSER_SESSION, IntPtr.Zero, 0);

(see http://support.microsoft.com/kb/195192/en) which shows one more time the nature of cookies holding.

这篇关于InternetExplorer.Application对象和cookie的容器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆