I have a problem : I want to check if an account exists on this website : freecraftmaps.fr
Here is my code :
public static Boolean doesAccountExist(string user, string pass)
{
WebBrowser wb = new WebBrowser();
wb.Navigate("https://www.freecraftmaps.fr/");
wb.ScriptErrorsSuppressed = true;
while (wb.ReadyState != WebBrowserReadyState.Complete) { Application.DoEvents(); }
wb.Document.GetElementById("login").SetAttribute("Value", user);
wb.Document.GetElementById("password").SetAttribute("Value", pass);
wb.Document.GetElementById("submit").InvokeMember("click");
object result = null;
new Thread(() =>
{
System.Threading.Thread.Sleep(200);
if (wb.Url.AbsoluteUri.EndsWith("erreur.php")) result = false;
else result = true;
}).Start();
while (result == null) { Application.DoEvents(); }
return (Boolean)result;
}
The problem is : it only works one time, when I call again the function, it throws an NullReferenceException on :
wb.Document.GetElementById("login").SetAttribute("Value", user);
Thanks,