I study C # and the idea arose to programmatically log in to the site. How to check whether I am authorized or not?

webBrowser1.Navigate("http://www.site.ru/"); webBrowser1.Document.GetElementById("username").SetAttribute("value", "user"); webBrowser1.Document.GetElementById("password").SetAttribute("value", "password"); foreach (HtmlElement he in webBrowser1.Document.GetElementsByTagName("input")) { if (he.GetAttribute("value").Equals("login")) { he.InvokeMember("click"); break; } } 
  • after clicking, the browser opens a new page, or loads new data ... It is enough to determine how the login page differs from the login field, to find any universal tag that is missing from the login page but is present on the page after the login, or vice versa, and look for him. if it is, it means that the login was successful ... well, something like that .. - Vladyslav Matviienko

1 answer 1

Check that a webBrowser1 been set in webBrowser1 , which corresponds to the situation when you are logged into this site - I think that it is possible to understand whether this is not the case for a cookie in 95% of cases.

  • one
    @ Asen2 welcome back: D - Zowie
  • thanks, so I’m probably gonna try to do it) - KoCaTKo
  • @AlexWindHope I can't even comment on the issues, so it's not interesting yet =) - Asen2