c# - WebBrowser control doesn't hold cookies -
i'm using webbrowser command sign in on page , retrieve cookie response sets in windows console application (c#).
the signing in runs smoothly. can see in fiddle sign in successful, , cookie is set. when seek cookie webbrowser control, code webbroser.document.cookie returns null.
here code
public void runbrowserthread(uri url) { var th = new thread(() => { var br = new webbrowser(); br.documentcompleted += browser_documentcompleted; br.navigate(url); application.run(); }); th.setapartmentstate(apartmentstate.sta); th.start(); } void browser_documentcompleted(object sender, webbrowserdocumentcompletedeventargs e) { var br = sender webbrowser; if (!datainputpassed) { console.writeline(br.document.body.innerhtml); br.document.getelementbyid("username").setattribute("value", "user"); br.document.getelementbyid("password").setattribute("value", "pass"); br.document.forms[0].invokemember("submit"); datainputpassed = true; } if (e.url.tostring().contains("osiguruvanje") && br.document.cookie != null) { console.writeline(br.document.body.innerhtml); } } why happening? there way control's internal webrequest , retrieve cookie there? bare in mind page i'm signing in to, makes several redirects, 1 of which, calling javascript form submition, using webrequest class won't much help.
c# cookies webbrowser-control console-application
No comments:
Post a Comment