Webbrowser控制登录后自动注销

时间:2016-08-06 04:27:56

标签: c# .net

我正面临着webbrowser控件的一些问题。我使用webclient登录网站。然后我在浏览器中显示网站。所以我从webclient获取cookie并使用InternetSetCookie将cookie设置为webbrowser,然后导航到该页面。接下来发生的事情是我在webbrowser中获取我登录的屏幕,但是它会立即注销 我不明白为什么会这样,我现在需要帮助。

我使用此函数在webbrowser中设置cookie的值..

[DllImport("wininet.dll", CharSet = CharSet.Auto, SetLastError = true)]
private static extern bool InternetSetCookie(string url, string name, string data);

public static bool SetWinINETCookieString(string url, string name, string data)
{
      return InternetSetCookie(url, name, data);
}

这是我获取数据并在webbrowser控件中发布新帖子的地方。

System.Text.Encoding encoding = System.Text.Encoding.UTF8;
   byte[] byteArray = encoding.GetBytes(sPostParameter);
   string authHeader = oBankcl1.PAYMENT_PAGE_AUTH_HEADER1;

   InteropServicescl oInteropServicescl1 = new InteropServicescl();
   oInteropServicescl1.ChangeUserAgent("Mozilla/5.0 (Windows T 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.116 Safari/537.36");
   CookieCollection oCookieCollection = Cookiecl.GetAllCookies(webClient.CookieContainer);
   AddCookieFromCookieColl(oCookieCollection);

  this.wbWebbrowser.Navigate("https://www.abc.co.in/add/main.jsf", string.Empty, byteArray, authHeader);

在这里,我在浏览器中看到我的网站,但它在1秒后退出,并提供登录屏幕。我不明白谁会触发注销。

0 个答案:

没有答案