Internet explorer InternetExplorer.Application对象和cookie容器

Internet explorer InternetExplorer.Application对象和cookie容器,internet-explorer,cookies,automation,Internet Explorer,Cookies,Automation,我用VB.NET编写了以下控制台应用程序: Sub Main() Dim ie As Object = CreateObject("InternetExplorer.Application") ie.Visible = True ie.Navigate2("http://localhost:4631/Default.aspx") End Sub 此程序使用automation对象启动IE窗口并导航给定url。我遇到的问题是,即使我启动应用程序的多个实例,使用此方法创建的

我用VB.NET编写了以下控制台应用程序:

Sub Main()
    Dim ie As Object = CreateObject("InternetExplorer.Application")
    ie.Visible = True
    ie.Navigate2("http://localhost:4631/Default.aspx")
End Sub
此程序使用automation对象启动IE窗口并导航给定url。我遇到的问题是,即使我启动应用程序的多个实例,使用此方法创建的IE窗口都共享同一个cookie容器。是否有任何参数可以用于指定为每个窗口创建不同的cookie容器

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

<%@ 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>

受保护的无效页面加载(对象发送方、事件参数e)
{
//将某些内容存储到会话中以创建cookie
会话[“foo”]“bar”;
响应.写入(Session.SessionID);
}

关于
CreateObject(“InternetExplorer.Application”)
您创建了一个Internet Explorer实例,您程序的所有实例都通过这个过程进行通信每个进程将保留cookie

您可以尝试在应用程序中改用
WebBrowser
控件(请参阅)。你可以在比较两种方法的信息中找到答案。如果在应用程序中使用
WebBrowser
控件,则应用程序的所有实例都将有自己的cookie集,但每个进程只有一组cookie,这与应用程序中
WebBrowser
控件的数量无关

在任何进程内,您可以随时清除有关以下调用的cookie

InternetSetOption(IntPtr.Zero, INTERNET_OPTION_END_BROWSER_SESSION, IntPtr.Zero, 0);
(请参阅)这再一次显示了饼干的性质