authentication - Log in to web site via c# fails -


i'm trying login website parsing purpose. while program runs seems login web site. can see fiddler. @ end of program, status code seems tobe 200, ı find myself not logged in.

string loginuri = "https://www.sample.com"; string username = "username"; string password = "password"; cookiecontainer cc = new cookiecontainer(); var handler = new httpclienthandler { cookiecontainer = cc }; var request = new httprequestmessage(httpmethod.post, loginuri); handler.allowautoredirect = true; request.content = new formurlencodedcontent(new dictionary<string, string>                                             {                                             { "return_url", "emagaza.php"},                                             { "user_login", "sampleuser"},                                             { "password", "sapmplepass"},                                             { "dispatch[auth.login]", "giriş yap"}                                             }); var client = new httpclient(handler);   var response = await client.sendasync(request); response.ensuresuccessstatuscode(); 

any attempt use cookies failed. tried this;

         httpwebrequest2.cookiecontainer = cc;         httpwebresponse response3 = (httpwebresponse)httpwebrequest2.getresponse(); 

and tried this;

        var handler2 = new httpclienthandler { cookiecontainer = cc };         var request2 = new httprequestmessage(httpmethod.get, loginuri);         var response2 = await client.sendasync(request2); 


Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -