Webbrowser control logout automatically after login RRS feed

  • Question

  • I am facing some issue with webbrowser control. I login to a site using webclient c#. 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 from webclient object 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);
      this.wbWebbrowser.Navigate("https://www.abc.co.in/add/main.jsf", string.Empty, byteArray, authHeader);

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

    please help me on this.i need this thing . i have trie latest version of ie from this post http://stackoverflow.com/questions/17922308/use-latest-version-of-ie-in-webbrowser-control

    Monday, August 8, 2016 6:29 PM


  • I'd try them over here.




    Regards, Dave Patrick ....
    Microsoft Certified Professional
    Microsoft MVP [Windows Server] Datacenter Management

    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees, and confers no rights.

    • Proposed as answer by Mike Laughlin Monday, August 8, 2016 7:05 PM
    • Marked as answer by Just Karl Monday, August 15, 2016 2:18 PM
    Monday, August 8, 2016 6:59 PM