0

I am facing some issue with webbrowser control. I login to a site using webclient. Then at a point I show website in browser. So I grab cookie from webclient and set cookies to webbrowser using InternetSetCookie and then navigate to the page. What happens next is I get screen in webbrowser where I login but it logout immidiatly.
I dont understand why it is happening, I need help at this point.

I use this function to set value of cookie in webbrowser..

[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);
}

Here is where I get data and make a new post in webbrowser control.

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);

here i see my website in browser but it logout after 1 sec and gives login screen. i dont understand who trigger logout.

Karan
  • 21
  • 7
  • Try this first, use the latest IE version : http://stackoverflow.com/questions/17922308/use-latest-version-of-ie-in-webbrowser-control –  Aug 06 '16 at 04:36
  • i tried this .. but still go to login screen. i see screen where i am login for a second and it logout. all cookie are available in fiddler request. – Karan Aug 06 '16 at 04:53
  • Possible duplicate of [Use cookies from CookieContainer in WebBrowser](http://stackoverflow.com/questions/4185171/use-cookies-from-cookiecontainer-in-webbrowser) – Sheng Jiang 蒋晟 Aug 06 '16 at 22:37
  • this is not duplicate. as my problem is different. i have already set cookie and it it being set properly. the problem is it logout website after page loaded. – Karan Aug 07 '16 at 03:35

0 Answers0