0

What i want is that it will navigate to the SignInPage.aspx but without showing this page in the webbrowser.

private void button1_Click(object sender, EventArgs e)
        {
            statuslabel.Text = "";
            webBrowser1.DocumentCompleted += WebBrowser1_DocumentCompleted;
            webBrowser1.Navigate("http://SignInPage.aspx");
        }

        private void WebBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            webBrowser1.DocumentCompleted -= WebBrowser1_DocumentCompleted;
            webBrowser1.DocumentCompleted += WebBrowser2_DocumentCompleted;

            try
            {
                webBrowser1.Document.GetElementById("UserName").InnerText = textBox1.Text.ToString();
                webBrowser1.Document.GetElementById("Password").InnerText = textBox2.Text.ToString();
                webBrowser1.Document.GetElementById("LoginButton").InvokeMember("click");
            }
            catch (Exception err)
            {
                string error = err.ToString();
                webBrowser1.DocumentCompleted -= WebBrowser2_DocumentCompleted;
            }
        }
moshe ralf
  • 489
  • 3
  • 12
  • 21

1 Answers1

0

Should use WebRequest and WebResponse. If you need cookies, hidden form fields etc the best way is to run it in Edge or Chrome and then use Fiddler to snoop on the HTTP traffic so you can recreate it in your program. Fiddler even lets you see the results of HTTPS so it makes it easy to find all the parameters/headers you need.

Kelly
  • 6,992
  • 12
  • 59
  • 76